Skip to content

Fix 14648 comma in string list - #14661

Merged
kriben merged 2 commits into
devfrom
fix-14648-comma-in-string-list
Sep 9, 2026
Merged

Fix 14648 comma in string list#14661
kriben merged 2 commits into
devfrom
fix-14648-comma-in-string-list

Conversation

@kriben

@kriben kriben commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Fixes #14648.

kriben added 2 commits August 31, 2026 15:36
Lists sent from Python over gRPC are serialized as text, and the list parser split on every comma, also commas inside a string. A category name like "Coal,Calcite" was therefore split in two, and set_discrete_property_category_names() failed with "CategoryValues and CategoryNames must have matching sizes".

The list parser is now quote-aware, and ignores commas inside quoted strings and inside nested brackets and parentheses. A quoted item is parsed as a quoted string also when the surrounding text is unquoted, as is the case for text coming from Python. The Python client quotes and escapes strings in lists and tuples when they contain separator characters.

Add unit tests for the field serialization and a Python test for the category names.
A quote or an opening bracket is only given special meaning when it is the first character of a value. Brackets and parentheses are treated as ordinary characters for text based values, as nested containers are not possible for these types. Text values are then parsed as before, also when they contain unbalanced brackets, parentheses or quotes.

Items in a tuple are not quoted by the Python client, as the tuple parser does not support quoted strings.

Add unit tests for text values containing separator characters, white space, file paths, numbers, nested containers and 3D vectors.
@kriben kriben self-assigned this Aug 31, 2026
@kriben
kriben marked this pull request as ready for review September 9, 2026 08:59
@kriben
kriben requested a review from magnesj September 9, 2026 08:59

@magnesj magnesj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement to support a fairly common usage pattern

for ( size_t i = 0; i < fieldValue.size(); ++i )
{
PdmFieldScriptingCapabilityIOHandler<T>::readFromField( fieldValue[i], outputStream, quoteNonBuiltins );
PdmFieldScriptingCapabilityIOHandler<T>::readFromField( fieldValue[i], outputStream, quoteStrings, quoteNonBuiltins );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this was a difficult bug to see due to default parameter values.

@kriben
kriben merged commit f38332b into dev Sep 9, 2026
21 checks passed
@kriben
kriben deleted the fix-14648-comma-in-string-list branch September 9, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python Bug in set_discrete_property_category_names

2 participants