Repository navigation
Conversation
An UpdateExpression whose paths name one element once as a map member and once as a list element, such as SET a.b = :b, a[0] = :z, was not checked as a whole. ExtendDB applied the actions in turn, and the action that did not fit the stored value failed with "The document path provided in the update expression is invalid for update". DynamoDB refuses the expression before it reads the item, with "Two document paths conflict with each other". Two paths where one is a prefix of the other, such as SET a = :b, a.b = :z, get "Two document paths overlap with each other" the same way; ExtendDB had no check for them either. validate_update_paths compares the paths of all clauses in expression order. Path one is the last path that meets a later one, and path two is the earliest later path it meets. UpdateItem runs it before the key attribute check, with "1 validation error detected: " ahead of the text. A TransactWriteItems Update runs it before the unused names and values check, with no prefix. Both keep the order of the checks that already ran before it. Measured in us-east-1 on 2026-11-25, each request sent twice. Fixes #811 Signed-off-by: Elise Ong <eliseong@amazon.com>
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks for this. I built the branch at 4723c28 and main at 6942157. On the branch, tests/test_update_expression_paths.py passes 11 of 11 tests, and on main 10 of them fail. cargo test -p extenddb-core -p extenddb-engine --lib passes 1243 and 978 tests, as the description says.
I also sent 37 request shapes to DynamoDB in us-east-1 on 1 December, each twice, with the same answer both times. The table did not exist, so a refusal ahead of the table lookup shows. They confirm the overlap and conflict texts, the TransactWriteItems text without 1 validation error detected: , and the rule that picks path one and path two. Seven of them confirm that rule on shapes where another rule names a different pair. For example, REMOVE a SET a.b = :b answers with the pair [a], [a, b], in that order. Apart from the unused value or name that the description lists, the branch gives the service's answer on every path refusal. It refuses no shape that the service accepts.
This needs two changes before it can merge:
- The upgrade manual needs an entry.
docs/versioning.mdsays that a change that makes ExtendDB answer a request as DynamoDB does ships in a minor release. It also says that the upgrade manual lists each such change under Behavior Changes by Release. Main appliesADD s :ss DELETE s :ssandREMOVE a.b, a.b, and the branch refuses both, as the service does. On TransactWriteItems the error code also changes, fromTransactionCanceledExceptionwith aValidationErrorreason toValidationException. 1.1.0 shipped on 27 November without this change, so the entry is the firstv1.2.0:heading. Please add the TransactWriteItems change to Breaking changes too. The documentation box in the checklist has a tick, but no file underdocs/changes. - The new path validation now answers ahead of an undefined value or name that the service names first. The comment on line 265 of
update_item.rshas the measured rows.
The other inline comments are smaller.
On the description:
- "23 UpdateItem shapes" and "20 of the 25 UpdateItem rows" disagree. Please give the right count, or say what each number counts.
- "The rows that still differ are listed under Notes" leaves out the rows in the comment on line 265. In that comment's two UpdateItem rows, main names the same fault as the service, with a text that lacks the envelope or the prefix. The sentence "No cell that main answers as the service does is answered differently by this branch" is true only because of those text differences. Please list the rows.
On the overlap with other PRs: #399 (opened 14 October) adds validate_update_paths_disjoint, the overlap half of this validation. #507, #597 and #1140 carry the same function. #507 has an approval, and its base is main. This PR closes #811, which #399 does not fix, and the description credits #399 and gives a merge plan. Please name #507 beside #399 in that plan. Please also say that whichever PR merges second deletes its function and that function's tests.
| // The service checks the paths ahead of the key attributes. It also | ||
| // checks them ahead of the table and of unused names and values, which | ||
| // this handler checks first. | ||
| extenddb_core::expression::validate_update_paths(&actions, &maps).map_err(|e| match e { |
There was a problem hiding this comment.
This call now answers ahead of an undefined value or name that the service names first. Measured on 1 December, each request twice:
| Request | DynamoDB | main | branch |
|---|---|---|---|
UpdateItem SET a.b = :q, a[0] = :z, :q not defined |
undefined value :q |
undefined value :q, without 1 validation error detected: |
conflict |
UpdateItem SET a.b = :b, a[0] = :z, condition attribute_exists(#q), #q not defined |
undefined name #q, in the ConditionExpression |
undefined name #q, without the envelope and the prefix |
conflict |
| TransactWriteItems Update, the first row's request | undefined value :q |
TransactionCanceledException |
conflict |
| TransactWriteItems Update, the second row's request | undefined name #q, in the ConditionExpression |
TransactionCanceledException |
conflict |
TransactWriteItems Update SET a = :b, a.b = :z, the same condition |
undefined name #q, in the ConditionExpression |
TransactionCanceledException, with the undefined #q as its reason |
overlap |
On main, both faults come from evaluation, after this call: the value from update_evaluator.rs line 131, and the name from the condition evaluation. So on UpdateItem, this change replaces the fault that main and the service name. Please refuse an undefined :value of the update actions, and an undefined #name or :value of the ConditionExpression, ahead of this call and ahead of line 581 of transact_write_items.rs. The walk that validate_unused_attributes does with collect_expr_refs already collects these references. #399 also reorders these checks, so the second of the two PRs to merge keeps one copy.
There was a problem hiding this comment.
Fixed in 6da1a96. validate_update_refs reads the ConditionExpression and then each action, its path and then its value, and refuses the first undefined #name or :value ahead of the path check, here and in TransactWriteItems. All five rows in your table now give the service's answer, and the wire tests pin them. An undefined #name in an update path is still refused earlier by each handler, as on main; the description lists those rows. #399 also reorders these checks, so the second of the two to merge keeps one copy.
| // this handler checks first. | ||
| extenddb_core::expression::validate_update_paths(&actions, &maps).map_err(|e| match e { | ||
| DynamoDbError::ValidationException(m) => { | ||
| DynamoDbError::ValidationException(format!("1 validation error detected: {m}")) |
There was a problem hiding this comment.
Nit: extenddb_core::error::validation_errors_detected(&[m]) builds this envelope. The engine already calls it in lib.rs and streams.rs.
There was a problem hiding this comment.
Done in 6da1a96. The envelope now comes from validation_errors_detected.
| }, | ||
| )?; | ||
| } | ||
| extenddb_core::expression::validate_update_paths(&actions, &maps)?; |
There was a problem hiding this comment.
An undefined #name after the first step of a path now stops here, without the Invalid UpdateExpression: prefix. This changes requests that have no path conflict. For a TransactWriteItems Update SET a.#u = :b with no ExpressionAttributeNames, DynamoDB answers Invalid UpdateExpression: An expression attribute name used in the document path is not defined; attribute name: #u. Main answers TransactionCanceledException, and the branch answers the same text without the prefix. prefix_expression_error(e, ExpressionKind::Update) gives the service's text here, as the condition check on the lines above does.
There was a problem hiding this comment.
Fixed in 6da1a96. validate_update_refs refuses that name with the Invalid UpdateExpression: prefix ahead of this line, and the path check result also goes through prefix_expression_error. SET a.#u = :b now gives the service's text, and a wire test pins it. A #name at the first step of a path is still refused earlier, in validate_no_key_updates, without the prefix, as on main.
| .collect(); | ||
| let resolved = resolve_paths(&paths, maps)?; | ||
| // `Some(true)` when the paths conflict, `Some(false)` when they overlap. | ||
| let meet = |a: &[ResolvedElement], b: &[ResolvedElement]| { |
There was a problem hiding this comment.
Main already has this classifier and this message. meeting in crates/engine/src/partiql/write/update.rs returns "conflict" for a member against an index, and "overlap" when the steps run out. first_overlap in the same file formats the same sentence, and path_list renders a path as render_path does. is_prefix and check_overlap in projection.rs give the overlap half for a ProjectionExpression. The loops can stay separate, because the three callers name different pairs. Please share one classifier and one message function, or say in the description why this copy stays.
There was a problem hiding this comment.
Done in 6da1a96. paths_meeting and paths_meet_message in projection.rs now serve validate_update_paths and the PartiQL first_overlap, and meeting and path_list are gone. check_overlap for ProjectionExpression uses paths_meet_message. It keeps is_prefix, because paths_meeting would also refuse a projection conflict such as a.b, a[0], which is a separate difference from #811; the description says so. The loops stay separate.
| } | ||
|
|
||
| #[test] | ||
| fn update_paths_accept_siblings() { |
There was a problem hiding this comment.
Please add two measured shapes that the service accepts and that a wrong comparison would refuse. The first is SET #d = :b, a.b = :z with #d bound to a.b, one attribute whose name contains a dot. The second is SET a = :b, b = a, with a path on the right side of SET. DynamoDB answered both with ResourceNotFoundException on a missing table, so it refused neither for its paths. With the current rows, a change that splits name values on . or compares right side paths still passes them.
There was a problem hiding this comment.
Added both to update_paths_accept_siblings in 6da1a96: SET #d = :b, a.b = :z with #d bound to a.b, and SET a = :b, b = a.
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns `DynamoDbError::ValidationException` with the `Invalid |
There was a problem hiding this comment.
Nit: this function also returns the errors of resolve_paths unchanged: an undefined #name, with no prefix, and a path that starts with an index. Please name both in # Errors.
There was a problem hiding this comment.
Done in 6da1a96. # Errors now names both: an undefined #name, and a path that starts with an index.
…conflict-2026-12-01
The path check answered ahead of an undefined #name or :value that DynamoDB names first. validate_update_refs now reads the ConditionExpression and then each update action, its path and then its value, and refuses the first undefined reference in that order, names and values alike, with the ConditionExpression or UpdateExpression prefix. UpdateItem and a TransactWriteItems Update run it just ahead of the path check, so the checks that already ran before it keep their place. A #name in an update path is still refused by the earlier check of each handler, as on main, except a name after the first step of a path on TransactWriteItems, which now carries the UpdateExpression prefix. The update path check and the PartiQL overlap check share one classifier, paths_meeting. Those two and the ProjectionExpression overlap check share one message, paths_meet_message. The UpdateItem envelope comes from validation_errors_detected. Two shapes the service accepts join the tests: a name that holds a dot, and a path on the right side of SET. The upgrade manual lists the change under v1.2.0. Measured in us-east-1 on 2026-12-01, each request sent twice. Signed-off-by: Elise Ong <eliseong@amazon.com>
|
Thanks. 6da1a96 adds the v1.2.0 entry to docs/manuals/07-upgrade-manual.md, and the description now lists the TransactWriteItems change under Breaking changes. The reply on line 265 covers the check order. The description now says what 23 and 25 count, lists the rows that still differ, and names #507 beside #399 in the merge plan. |
LeeroyHannigan
left a comment
There was a problem hiding this comment.
Thanks for the fixes and the replies. I built 6da1a96: cargo test -p extenddb-core -p extenddb-engine --lib passes 1263 and 981 tests, and clippy and fmt are clean. CI passes 76 checks. I sent the 1 December requests, 34 of them and each twice, to a dev-mode server built from this head. The five rows of my comment on line 265 and the SET a.#u = :b of the comment on line 581 now give the service's answer. No other row changed, and tests/test_update_expression_paths.py passes 15 of 15.
I sent 13 more requests to DynamoDB in us-east-1 today, each twice, with the table missing. Rows 3 to 8 of update_refs_name_the_first_undefined_reference get the names and values the test expects. SET #u = :b with the condition attribute_exists(#q), where neither name is defined, gets #q. GetItem with the ProjectionExpression a.b, a[0] gets the conflict text, as the description says. The other five requests are in the comment on line 417 of the upgrade manual.
Both conditions of the first round are met, and so are the smaller comments and the description points. One change is still needed. The new upgrade-manual entry says that 1.1.0 refused an undefined reference with another text, but 1.1.0 applied some of those requests. The comment on line 417 has the rows.
The comment on resolver.rs:397 is smaller. On the description, the list of rows that still differ from the service leaves out two TransactWriteItems rows of 1 December. With SET a.b = :b, a[0] = :z on a missing table, or with an empty key value, the service names the conflict. This branch answers ResourceNotFoundException or the empty key refusal, as main does. Please add them.
The merge plan still holds. #399, #507, #597 and #1140 are open and change the same functions.
#1093 merged at 08:59 UTC and adds a v1.2.0: entry at the top of the same section, so the upgrade manual now conflicts with main. Both entries can stay.
| `ConditionExpression` first and then each action, its path and then its value. | ||
| The text starts with `Invalid ConditionExpression: ` or `Invalid | ||
| UpdateExpression: `, and on `UpdateItem` with `1 validation error detected: `. | ||
| 1.1.0 answered these on `UpdateItem` without `1 validation error detected: `, |
There was a problem hiding this comment.
1.1.0 read a reference only when it evaluated it, so it applied some requests that this release refuses. I sent these to main and to this head on an item {pk, y: 1, a: {b: 1}}, and to DynamoDB in us-east-1 today with the table missing, each twice:
| Request | DynamoDB | main | this head |
|---|---|---|---|
UpdateItem SET x = if_not_exists(y, :q), :q not defined |
undefined value :q |
applied, x written |
as DynamoDB |
UpdateItem SET x = :b, condition attribute_exists(pk) OR #q = :b, #q not defined |
undefined name #q, in the ConditionExpression |
applied | as DynamoDB |
UpdateItem SET x = :b, condition attribute_not_exists(pk) AND #q = :b |
undefined name #q, in the ConditionExpression |
ConditionalCheckFailedException |
as DynamoDB |
| TransactWriteItems Update, the first row's request | undefined value :q |
applied | as DynamoDB |
| TransactWriteItems Update, the second row's request | undefined name #q, in the ConditionExpression |
applied | as DynamoDB |
So the refusal is right. This sentence says that 1.1.0 refused these with another text, though, and lines 425 to 428 say it answered them on TransactWriteItems with TransactionCanceledException. Please say that 1.1.0 applied such a request when it did not reach the reference, or answered ConditionalCheckFailedException. This release refuses it and writes nothing. Breaking changes needs the same point. Please also add the first two rows to the wire test.
| } | ||
|
|
||
| /// The references of `expr` in expression order, left to right. | ||
| fn refs_in_order<'a>(expr: &'a super::ast::Expr, out: &mut Vec<Ref<'a>>) { |
There was a problem hiding this comment.
refs_in_order walks the same expression arms as collect_expr_refs at line 498, and path_refs_in_order is collect_path_refs at line 594, with a list in place of two sets. first_undefined at line 473 also writes the two texts of ExpressionMaps::resolve_name and resolve_value_for again. Please keep one ordered walk that both callers use, and build the two refusals from those two functions. If a copy has to stay, please say why in the description.
What
UpdateItem and a TransactWriteItems Update now refuse an
UpdateExpressionwhose document paths meet. Two paths meet when they are equal step by step until one ends (they overlap, as inSET a = :b, a.b = :z) or until a step where one names a map member and the other a list index (they conflict, as inSET a.b = :b, a[0] = :z). The service answers:with
overlapin place ofconflictfor an overlap. TransactWriteItems gives the same text without1 validation error detected:. Nothing is written.validate_update_pathsincrates/core/src/expression/resolver.rscompares the paths of all four clauses in expression order, after#nameresolution. Path one is the last path that meets a later path, and path two is the earliest later path that it meets. On the service, overlap and conflict are one check:SET a.b = :b, a[0] = :z, a = :banswers the overlap[a, [0]], [a], andSET a = :b, a.b = :b, a[0] = :zanswers the conflict[a, b], [a, [0]].The service names an undefined
#nameor:valueahead of the paths.validate_update_refsreads theConditionExpressionand then each action, its path and then its value, and refuses the first undefined reference in that order, names and values alike, with theInvalid ConditionExpression:orInvalid UpdateExpression:prefix. UpdateItem and a TransactWriteItems Update run it just ahead of the path check.The update path check and the PartiQL overlap check share the classifier
paths_meeting. Those two and the ProjectionExpression overlap check share the messagepaths_meet_message, incrates/core/src/expression/projection.rs. The upgrade manual lists the change under v1.2.0.On main, ExtendDB did not compare the paths. It applied an overlap or a conflict whose actions all fit the stored value, such as
REMOVE a.b, a.borREMOVE a.b, a[0]on a map, and answered any other withThe document path provided in the update expression is invalid for updatefrom the action that did not fit.Why
Closes #811
Testing done
aa list,aabsent, no item), so the shapes make 25 UpdateItem rows. A TransactWriteItems Update was sent for 5 of the shapes. Each request was sent twice and got the same answer both times. Every refused request left the item unchanged.BETWEEN,IN,NOTand nested parentheses, and beside the other faults above. No shape that main answers as the service does is answered differently by this branch.tests/test_update_expression_paths.py(new, dual-target): 15 passed against DynamoDB and against this branch. On main, 14 of the 15 fail.update_paths_answer_as_the_servicepins the kind and both paths for 17 shapes.update_paths_accept_siblingschecks 5 shapes the service accepts, among them a name that holds a dot and a path on the right side of SET.update_refs_name_the_first_undefined_referencechecks 8 shapes.cargo fmt --all -- --check,cargo test -p extenddb-core --lib(1263 passed) andcargo test -p extenddb-engine --lib(981 passed).cargo clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warningsis clean apart from the unusedline_lenincrates/core/tests/data_file_decode_peak.rson macOS, which main has too.Notes
The rows that still differ from the service. main gives the same answer on each:
SET a.b = :b, a[0] = :zwith an unused value answers the unused value, where the service answers the conflict. These are 25 November cases 6, 10, 18 and 23. TransactWriteItems answers these as the service does.#namein the path of an update action is refused by an earlier check of each handler. On UpdateItem that check reads every step of the path and answers without1 validation error detected:and withoutInvalid UpdateExpression:, as in case 19. On TransactWriteItems it reads the first step of the path and answers without the prefix. On both operations it names that#nameahead of a reference that the service names first, as inSET #u = :bwith the conditionattribute_exists(#q).Moving these checks also moves the nesting and number checks of
ExpressionAttributeValues, which the service runs first. #399 reorders those checks, so this PR leaves them in place.The ProjectionExpression check keeps its own prefix test,
is_prefix. Withpaths_meetingit would also refuse a conflict such asa.b, a[0]. The service refuses that conflict too, but it is a separate difference from #811, so this PR leaves the check as it is.On the overlap with other PRs: #399 and #507 add
validate_update_paths_disjoint, the overlap half of this check, and #597 and #1140 carry the same function. ForSET a.b = :b, a.c = :b, a = :bthe service names[a, c], [a], where the first pair in expression order is[a, b], [a], so the overlap half alone cannot answer as the service does. Whichever of this PR and #399 or #507 merges second deletes its copy of the check and that copy's tests: if this PR merges first, the other PR deletesvalidate_update_paths_disjointand its tests and callsvalidate_update_paths; if the other merges first, this PR deletesvalidate_update_paths_disjointand its tests on rebase. #399 also reorders the checks thatvalidate_update_refsorders here, and the second of those two to merge keeps one copy.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
UpdateExpressionwhose paths overlap or conflict is now refused, as on the service. On main an overlap, and a conflict whose actions all fit the stored value, were applied.#nameor:valuenow answersValidationException, and no item of the transaction runs. On main the ones it did not apply answeredTransactionCanceledExceptionwith aValidationErrorreason.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.