Skip to content

fix(core): give the document path text for a list index past the end - #1226

Open
LeeroyHannigan wants to merge 3 commits into
mainfrom
fix/1216-list-index-past-end-path
Open

LeeroyHannigan wants to merge 3 commits into
mainfrom
fix/1216-list-index-past-end-path

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

What

A SET or ADD path can go through a list index past the end of the list and continue after it. ExtendDB answered such a path with The provided expression refers to an attribute that does not exist in the item. DynamoDB answers The document path provided in the update expression is invalid for update.

The change is in crates/core/src/expression/update_evaluator.rs. The index arm of set_nested (SET) now sends an index past the end to the existing arm with the document path text. This change deletes the branch that wrote the absent attribute text for it. #596 made the same change for ADD in navigate_to_existing_parent_map, which main now has. An index past the end as the last element of a SET path still appends the value.

Why

DynamoDB's answers, measured in us-east-1 on 20 November 2026 on an item whose k is [4, 5] and m is {"x": 1}. Each request went out twice and got the same answer both times. :v is {"N": "1"}.

Request DynamoDB ExtendDB before this change
UpdateItem SET k[5].x = :v the document path text the absent attribute text
UpdateItem ADD k[5].x :v the document path text the absent attribute text
UpdateItem SET k[5][0] = :v the document path text the absent attribute text
UpdateItem ADD k[5][0] :v the document path text the absent attribute text
UpdateItem SET k[5].x = :v, a = zz the document path text the absent attribute text
ExecuteStatement UPDATE "<table>" SET k[5].x = 1 WHERE pk = 'em-upd-operand' the document path text the absent attribute text
TransactWriteItems, one Update SET k[5].x = :v TransactionCanceledException, a ValidationError reason with the document path text the same, with the absent attribute text
BatchExecuteStatement, SET a = 9 on another item, then SET k[5].x = 1 CapacityUnits 2.0, the second response with the document path text 1.0, the absent attribute text
UpdateItem SET k[5] = :v served, k becomes [4, 5, 1] the same
UpdateItem SET m.q.x = :v the document path text the same

With this change, ExtendDB answers each row with DynamoDB's text. Since #596 merged, main already gives the two UpdateItem ADD rows that answer. The batch row now costs 2.0 as on DynamoDB, because the batch charges a failed UPDATE with the document path text.

Fixes #1216

Testing done

  • cargo test -p extenddb-core --lib: 1147 passed. cargo test -p extenddb-engine --lib: 870 passed.
  • cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warnings and cargo +1.97.0 fmt --all -- --check are clean. cargo +1.91.1 check -p extenddb-core --lib passes, so the if let chain of the ADD arm builds on the minimum Rust version.
  • The unit test a_path_through_a_list_index_past_the_end holds three of the refused UpdateItem paths: SET k[5].x, SET k[5][0] and SET m.q.x. update_add_parent_tests.rs from UpdateExpression ADD creates no missing map on its path #596 holds the ADD form. With the change reverted, the test fails.
  • Against ExtendDB on SQLite, tests/test_partiql_batch.py, tests/test_partiql_item_depth.py, tests/test_partiql_write.py, tests/test_index_key_validation_on_update.py and tests/test_item_operations.py passed 702 tests, with 3 expected failures.
  • Two rows join the table of test_an_error_of_the_item_operation_names_the_table in tests/test_partiql_batch.py: a path through an index past the end, and a value read at one. DynamoDB gave both answers in the form the test sends them. The first row fails against a server built from main. The test's item now holds a list l, and DynamoDB gives the other 13 rows of the test the answers they expect with it.

Line counts over main after the merge: production +3 -9, tests +44 -2.

Merge of 25 November

#596 merged first. 259f3a851 merges main at a417b2f82 and takes #596's navigate_to_existing_parent_map, which answers an ADD path through an index past the end with the document path text. 63d4a1d88 drops the ADD row of this PR's unit test, because #596's test sends the same shape. At 63d4a1d88, cargo test -p extenddb-core --lib passed 1167 tests, and cargo fmt --check is clean. At the merge, cargo test -p extenddb-wasm-adapter passed its 3 unit tests and the parity corpus, and cargo check -p extenddb-engine --no-default-features --lib and clippy with -D warnings on core are clean. The cargo commands ran with --locked.

Not in this PR:

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, 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


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.

A SET or ADD path can go through a list index past the end of the list.
When more path elements follow that index, ExtendDB answered "The
provided expression refers to an attribute that does not exist in the
item". DynamoDB answers "The document path provided in the update
expression is invalid for update". A path through a missing map key
already gets that text.

Each request was measured twice in us-east-1 on 20 Nov 2026. UpdateItem
answers the document path text for SET k[5].x, ADD k[5].x and
SET k[5][0], where k holds two elements. ExecuteStatement and
BatchExecuteStatement answer it for SET k[5].x, and TransactWriteItems
cancels with it as a ValidationError reason. With the index last,
SET k[5] still appends the value.

set_nested and navigate_to_parent_map_or_create now let an index past
the end reach the arm that returns the document path text. A
BatchExecuteStatement now charges such a statement the write units of
its item, as DynamoDB does.

Fixes #1216.
#596 rewrote the ADD path walk as `navigate_to_existing_parent_map`, which
answers an index past the end with the document path text. The merge takes
main's function, so this branch keeps only its SET change in `set_nested`.
#596 merged first with `update_add_parent_tests.rs`, which sends
`ADD l[5].a :one` and expects the document path text. The ADD row of
`a_path_through_a_list_index_past_the_end` sent the same shape, so it goes,
and the test keeps the SET rows that this PR changes.
@navareamol navareamol self-assigned this Nov 30, 2026

@navareamol navareamol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the cost claim has no test. The description says the batch row (SET a = 9 on another item, then SET k[5].x = 1) now costs 2.0. That comes from is_charged_failure in batch.rs, which charges a failed update only when its text is in UPDATE_FAILURES, so it moves with this change. On SQLite at 63d4a1d the batch reports 2.0, and on main 1.0. The two rows you added go to test_an_error_of_the_item_operation_names_the_table, which does not read ConsumedCapacity, and test_a_failed_write_is_charged_on_its_table has a document path row only for SET a.b = 1. Could you add a row there whose second statement is SET l[5].x = 1 on an item that holds a short list l, next to the document-path row? cap-ok2 holds no l, so the row needs its own item, or main would already give the document path text for it. The ExecuteStatement and TransactWriteItems rows of the table have no wire test either. They pass on SQLite here, so a row for each would keep them.

The comment on the new rows says they were measured "on a table keyed on pk alone, after a statement that succeeds", but the test sends one statement to gtable, which has pk, sk and a GSI. The description says DynamoDB gave both answers in the form the test sends them. Which one is right? If the second, could you update the comment?

A question, not a condition: the update evaluates each SET value and then its path, clause by clause. Here SET k[5].x = :v, a = zz answers the document path text, but SET a = zz, k[5].x = :v answers that the attribute does not exist. Did you measure the second order on DynamoDB?

I will approve once the 2.0 charge has a test row and the comment on the new rows matches what was measured.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A SET path that goes through a list index past the end answers the absent attribute text, where DynamoDB answers the document path text

2 participants