fix(dynamodb): PartiQL UPDATE param order, nested REMOVE, non-ASCII WHERE panic#2013
Merged
Conversation
…HERE panic Three DynamoDB correctness/robustness fixes from the cycle-6 bug audit. - PartiQL UPDATE positional parameters were swapped. `UPDATE t SET x=? WHERE y=?` bound the SET value from the WHERE parameter and vice versa, because WHERE was evaluated from parameter index 0 and SET started after it. Since SET is textually first, SET now consumes parameters[0..set_count] and WHERE the rest — a silent wrong-row-match + wrong-value-write before. - UpdateExpression REMOVE of a nested path was a no-op. `REMOVE profile.middle` / `REMOVE tags[0]` removed a literal top-level key named "profile.middle" (which never exists) instead of descending into the document. A new remove_path resolves dotted map paths and list indices (mirroring the SET writer), so the nested attribute is actually deleted; missing paths stay a silent no-op as in AWS. - split_partiql_and_clauses could panic on a non-ASCII WHERE clause. It built an uppercased copy with Unicode to_uppercase() (which can change byte length) then sliced it by byte indices bounds-checked against the original string, so a length-shrinking char (e.g. 'ff' -> "FF") ran the slice past the end and dropped the connection. Now uses to_ascii_uppercase(), keeping the buffers byte-aligned. Adds unit tests (remove_path nested/list/missing, non-ASCII split no-panic) and e2e tests (parameterized UPDATE order, nested REMOVE round-trip).
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.
Bug-hunt batch 2 (cycle 6). Three DynamoDB fixes.
UPDATE t SET x=? WHERE y=?bound the SET value from the WHERE parameter and vice versa — WHERE was evaluated from parameter index 0 and SET started after it. Since SET is textually first, SET now consumesparameters[0..set_count]and WHERE the rest.REMOVE profile.middle/REMOVE tags[0]removed a literal top-level key named"profile.middle"instead of descending. A newremove_pathresolves dotted map paths and list indices (mirroring the SET writer); missing paths stay a silent no-op like AWS.split_partiql_and_clausesuppercased with Unicodeto_uppercase()(can change byte length) then sliced by byte indices bounds-checked against the original string — a length-shrinking char ('ff'->"FF") ran the slice past the end and dropped the connection. Nowto_ascii_uppercase(), keeping buffers byte-aligned.Tests
Unit:
remove_path(nested map / list index / missing-path no-op), non-ASCII split no-panic. E2E: parameterized UPDATE order round-trip, nested REMOVE round-trip. Full dynamodb lib suite (322) + partiql e2e (7) green.Builds clean;
clippy --all-targets -D warningsclean; fmt clean.Summary by cubic
Fixes three DynamoDB issues: corrects PartiQL
UPDATEparameter binding order, makesREMOVEhandle nested paths and list indices, and prevents a panic on non-ASCIIWHEREclauses. Prevents wrong-row matches/writes and avoids connection drops on Unicode input.UPDATE: bind?in textual order.SETconsumes the first N params;WHEREuses the rest.REMOVE: resolves dotted paths and list indices (e.g.,profile.middle,tags[0]). Missing paths are no-ops.ff.Written for commit 60d431d. Summary will update on new commits.