Handle brackets inside string arguments in split_args#2164
Closed
winklemad wants to merge 1 commit into
Closed
Conversation
split_args treated every bracket and quote as structural, so a closing bracket inside a quoted string argument (e.g. reason="closed ]" or an emoticon "Hello :)") raised ValueError and crashed Colang flow parsing. Track string state so that while inside a quoted string only the matching closing quote is special and brackets, commas and the other quote type are literal, matching the sibling splitters (word_split, char_split, params_tokenize). Signed-off-by: winklemad <winklemad@outlook.com>
winklemad
force-pushed
the
fix/split-args-brackets-in-strings
branch
from
July 11, 2026 19:24
cc7e807 to
000d69b
Compare
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
split_args(the Colang 1.0 argument parser innemoguardrails/colang/v1_0/lang/utils.py) treats every bracket and quote as structural. While inside a quoted string argument, a closing bracket),],}— or the other quote character — is still handled as syntax, so it raisesValueErrorand crashes flow parsing.This hits ordinary string values: an emoticon, a citation marker, or any clause that ends with a bracket.
It also crashes through the public parse path — any Colang 1.0 flow with such an inline string parameter fails to parse:
The function's own docstring says it "correctly handles strings and lists/dicts", and the sibling splitters in the same module (
word_split,char_split,params_tokenize) already track string state — onlysplit_argsdoesn't.Fix
Add a real in-string short-circuit: while the top of the stack is a quote, only the matching closing quote is special; brackets, commas, and the other quote type are literal text. This preserves list/dict argument parsing and still raises
ValueErrorfor genuinely unbalanced unquoted brackets (the behavior added in #2145).Test Plan
Added
test_split_args_bracket_inside_stringtotests/test_parser_utils.py, covering closing brackets)]}, an emoticon, a citation marker, a comma, and the other quote character inside a quoted string, plus a bracket-in-string argument alongside a normal one. The new cases fail ondevelop(ValueError) and pass with the fix; the existingtest_1and the unbalanced-unquoted-bracket cases still pass.No linked issue — found by reading the code.