fix(dynamodb): paren-aware comma split in parse_update_clauses#368
Merged
vieiralucas merged 2 commits intofaiscadev:mainfrom Apr 14, 2026
Merged
Conversation
list_append(#a, :b) was silently no-oping because parse_update_clauses
split clause content on all commas without regard for parentheses depth.
SET #0 = list_append(#0, :0) was torn into two tokens at the inner comma:
- "#0 = list_append(#0" → apply_set_list_append got rest="#0", no ')' → early return
- ":0)" → treated as a malformed assignment, silently dropped
Fix: replace content.split(',') with split_on_top_level_keyword(content, ","),
the existing paren-depth-aware helper already used by split_on_and/split_on_or.
Five new unit tests added (all failing before the fix):
- parse level: list_append(a,b) stays as 1 assignment; outer comma still
splits two SET assignments
- integration: empty-list repro, nonempty-list append, list_append mixed
with a plain SET in the same expression
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
|
Thanks for the thorough debugging and the test coverage — root cause analysis is spot on, and reusing the existing |
7 tasks
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.
Summary
UpdateItemwith alist_appendexpression silently no-oped:The item's target attribute was left unchanged even though the call returned no error, and the attribute already existed as an empty list (so
if_not_existswas not the issue). Confirmed broken in v0.7.1 and v0.9.0 against real DynamoDB.Root cause
parse_update_clausessplit each action clause's content on every comma naively:The expression
#0 = list_append(#0, :0)was torn apart at the comma inside the function call, producing two bogus tokens:#0 = list_append(#0— sent toapply_set_list_appendasrest = "#0"(no closing)):0)— treated as a separate malformed assignment, silently ignoredIn
apply_set_list_append,rest.strip_suffix(')')found no)and returned early — no write, no error.Fix
Replace the naive
split(',')with the existingsplit_on_top_level_keyword(content, ",")helper, which is already paren-depth-aware and is used bysplit_on_and/split_on_orfor exactly the same reason. Commas inside balanced parentheses are now left intact.Test plan
Five new unit tests (all failing before the fix):
test_parse_update_clauses_list_append_single_assignment— parse level:list_append(a, b)stays as 1 assignment, not 2test_parse_update_clauses_list_append_mixed_with_plain_set— parse level: outer comma still splits two SET assignments correctlytest_list_append_into_empty_list— exact repro from the bug report (empty existing list)test_list_append_into_nonempty_list— append to a non-empty existing listtest_list_append_combined_with_plain_set—list_appendand plain SET in the same expression both applycargo test -p fakecloud-dynamodb— 98 pass (was 93, +5 new)cargo clippy -p fakecloud-dynamodb -- -D warnings— cleancargo fmt --check— cleanlist_append, and the bug was purely in the comma tokeniser.Summary by cubic
Fixes parenthesis-aware splitting of SET clauses in
fakecloud-dynamodbUpdateExpression parsing solist_append(#a, :b)applies correctly instead of no-oping.Bug Fixes
parse_update_clauseswithsplit_on_top_level_keyword; add tests forlist_appendparsing and execution, including mixed SETs and empty/non-empty list appends.Refactors
cargo fmt(style-only).Written for commit 89f8716. Summary will update on new commits.