Repository navigation
fix(engine): answer TransactGetItems {"Item": {}} for an item its projection leaves empty - #1571
hitesh96db wants to merge 2 commits into
Conversation
…jection leaves empty Fixes #867. Signed-off-by: Hitesh Sharma <hts@amazon.com>
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 2d7d06b. 1 finding: 1 Important.
The change makes TransactGetItems answer {"Item": {}} for an existing item whose projection selects nothing, keeping {} for a missing item and for a list index past the end. Confirmed: cargo test -p extenddb-core -p extenddb-engine --lib passes (1261 and 981 tests) on the head and on the head merged with the current origin/main; the new Python test passes on SQLite (6 transact_get tests); putting the base's filter back, and forcing the past-list-end helper to false, each fail that test (at the first assertion and at the l[7] assertion respectively).
- Important
crates/engine/src/transact_get_items.rs:183— Live DynamoDB answered{}(not{"Item": {}}) for an existing item with projectionnopeorn.b, so this change moves ExtendDB away from the service.
| // An existing item whose projection selects nothing is | ||
| // `{"Item": {}}`, not the missing-item `{}`. Measured exception: | ||
| // an index past the end of a list answers `{}` (issue #867). | ||
| Some(p) => opt |
There was a problem hiding this comment.
Important
The change at transact_get_items.rs:183-187 answers {"Item": {}} for an existing item whose projection selects nothing, on the premise (issue #867) that DynamoDB does so. Measured on 2026-12-03 in us-east-1, DynamoDB's raw response body for TransactGetItems on an existing item was {"Responses":[{}]} for nope, n.b (n a number), l[7], l[0].x, m.zz and l[0][1]; l[0] and l[7],n returned the selected attributes. A missing key with no projection also gave {"Responses":[{}]}. GetItem on the same item answered {"Item":{}} for all of those. So DynamoDB's TransactGetItems does not distinguish them today, and the head now answers {"Item": {}} for nope, n.b on ExtendDB (new test passes on SQLite) where main and the service answer {}. A client that relied on {} for an empty projection (as the service gives it) now sees a different entry, and the upgrade-manual entry at docs/manuals/07-upgrade-manual.md:428 documents the new behavior as if it matched the service.
Fix: re-measure the issue's 2026-11-05 result; if the service now answers {}, revert the change (the reaches_past_list_end helper, projection.rs:102-125, then has no use) or record the divergence in docs/differences-from-dynamodb.md; tests/python/test_transactions.py:261-287 (expects {"Item": {}} for nope and n.b) and the manual entry change with it; the test also fails against the live service (first assertion, nope) when run through the live wrapper, which the issue asked for ("against both targets"). No migration.
Evidence: aws dynamodb transact-get-items --debug with Key pk=k1, ProjectionExpression nope printed b'{"Responses":[{}]}'; extenddb-live-ddb-pytest tests/python/test_transactions.py -k projection_selecting_nothing failed at assert get("k1", "nope") == {"Item": {}}. The behavior may have changed since the issue's measurement; the PR body says it did not call DynamoDB.
There was a problem hiding this comment.
You are right, thanks. Your raw-body measurement (2026-12-03, us-east-1) shows TransactGetItems answering {"Responses":[{}]} for an existing item whose projection selects nothing (nope, n.b, l[7], l[0].x, m.zz, l[0][1]), the same as a missing item, and the new test fails against the live service. That is what main already answers, and main's test_transact_get_empty_projection_omits_item has asserted it since May; cf73b0e flipped that test to follow #867, which was wrong. Closing this PR without merging; #867 will be closed as not reproducible with your measurement.
…ects nothing
test_transact_get_empty_projection_omits_item asserted that the response entry has no Item, the answer this change fixes. DynamoDB answers {"Item": {}} for an existing item whose projection resolves to no attribute (measured 2026-11-05, #867).
Signed-off-by: Hitesh Sharma <hts@amazon.com>
|
Closing without merging. LJMart11 measured DynamoDB on 2026-12-03 (raw response body, us-east-1): TransactGetItems answers |
What
TransactGetItemsnow answers{"Item": {}}for an existing item whoseProjectionExpressionselects no attribute (a name the item lacks, ora.bwhereais a number). A missing item still answers{}. Incrates/engine/src/transact_get_items.rsthe projected item was filtered out when empty, which made it look like a missing item. The filter is dropped.One exception is kept: a list index past the end of the list (
l[7]) still answers{}, as the issue measured on DynamoDB.Projection::reaches_past_list_endincrates/core/src/expression/projection.rsdetects that case. The issue asks for that case to be measured again; I did not call DynamoDB, so it follows the issue's measurement and should be re-measured before merge. If DynamoDB answers{"Item": {}}there, delete the helper and its call.The change is in the engine, so it applies to every backend. GetItem and BatchGetItem already return the empty item.
Open PR #826 touches TransactGetItems validation. This PR edits only the response-building step at the end of the handler, so a conflict should be small.
Why
Fixes #867. A client cannot tell an existing item from a missing one.
Testing done
cargo test -p extenddb-core --lib projection: 38 passed, including the newreaches_past_list_end_only_for_a_missing_list_element.cargo test -p extenddb-engine --lib transact: 28 passed.test_transact_get_projection_selecting_nothingintests/python/test_transactions.py(nonexistent attribute, path into a number,l[7], missing item), run on the SQLite backend: 6transact_gettests passed. The pre-fix failure was not run on a build; by reading, the removed filter made the first two cases answer{}.cargo fmt --all -- --checkandcargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --lib -- -D warningsclean.--all-targetsfails on an unused variable incrates/core/tests/data_file_decode_peak.rs, which is present on main.Upgrade manual:
v1.2.0:entry added.Checklist