fix(workflows): preserve commas inside quoted list-literal elements#3134
Open
jawwad-ali wants to merge 1 commit into
Open
fix(workflows): preserve commas inside quoted list-literal elements#3134jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
The simple-expression evaluator parsed a list literal with a naive
`inner.split(",")`, which splits on commas inside quoted strings (and
nested brackets). So `{{ ["a, b", "c"] }}` evaluated to three items
(`["a", "b", "c"]`) instead of two, silently corrupting `fan-out` `items:`
and any list expression that contains a comma inside a quoted element.
Split list-literal elements on top-level commas only, ignoring commas
inside quotes or nested brackets, via a small `_split_top_level_commas`
helper. Plain and empty lists are unchanged.
Add tests covering quoted commas, nested lists, and the existing
plain/empty cases.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
The workflow simple-expression evaluator parsed list literals with a naive
inner.split(","):That splits on commas inside quoted strings (and nested brackets), so a list element containing a comma is silently broken into multiple elements:
{{ ["a, b", "c"] }}→["a", "b", "c"](3 items) instead of["a, b", "c"](2 items){{ ["x, y, z"] }}→["x", "y", "z"]instead of["x, y, z"]This silently corrupts any list expression with a comma inside a quoted element — most importantly a
fan-outstep'sitems:, where it changes the number of iterations and the data passed to each one, with no error raised.Fix
Split list-literal elements on top-level commas only, ignoring commas inside quotes or nested brackets, via a small
_split_top_level_commashelper. Per-element evaluation is unchanged (elements can still be variables, nested lists, etc.), and plain/empty lists behave exactly as before.Testing
Tested locally with
uv run specify --help(exit 0)Ran existing tests with
uv sync && uv run pytestuvx ruff check src/— All checks passeduv run pytest tests/test_workflows.py— 295 passed, 1 skipped; the only failures on my Windows host are the pre-existingos.symlinkWinError 1314privilege tests (unrelated to this change).New test
tests/test_workflows.py::TestExpressions::test_list_literal_preserves_quoted_commascovers quoted commas, nested lists, and the existing plain/empty cases. It fails onmain(["a", "b", "c"]) and passes with this fix.AI Disclosure
Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI located the naive split, implemented the quote/bracket-aware helper, and wrote the tests; I confirmed the corruption reproduces on
mainand that the fix resolves it (and is a no-op for plain lists) before submitting. I'll disclose if any review responses are AI-assisted as well.