Skip to content

fix(core): ignore a top-level TableName in TransactGetItems and TransactWriteItems - #1579

Open
navareamol wants to merge 2 commits into
mainfrom
fix/1535-transact-toplevel-tablename
Open

navareamol wants to merge 2 commits into
mainfrom
fix/1535-transact-toplevel-tablename

Conversation

@navareamol

Copy link
Copy Markdown
Collaborator

What

TransactGetItems and TransactWriteItems now accept a top-level TableName of any JSON type and ignore it. Any other unknown top-level member is still refused with SerializationException. The refusal text for that member now lists TableName among the expected members, for example "expected one of TransactItems, TableName, ReturnConsumedCapacity". The status and the code are unchanged, and no test asserts the old text.

The change is in crates/core/src/types/transaction.rs: TransactGetItemsInput and TransactWriteItemsInput get a TableName member that deserializes into serde::de::IgnoredAny and is never read.

Why

Refs #1535

Issue #1535 measures that DynamoDB answers a request with a top-level TableName as it answers the same request without it (19 values, missing table inside TransactItems). Both input types carry #[serde(deny_unknown_fields)] (transaction.rs lines 18 and 82 on main), so TableName was refused as an unknown field.

Reproduced on SQLite from a build with the change reverted: the new wire test fails 4 of 6, the 4 being the requests that carry a TableName (2 operations, a missing-table request and an existing-table request each).

Side effects:

  • The table name gate (table_name_gate.rs, check_transact_items) and the cross-account check (cross_account.rs, batch_or_transaction) read only the members of TransactItems. They never read the top-level member, so a stray TableName gets no name or ARN checks, as the issue expects.
  • Throttling (With throttling on, a top-level TableName in a batch or transaction request throttles it against that table #1536): by code reading, handler.rs registers and throttle-checks extract_table_name(&input) before the engine deserializes the request, on main and on this branch alike. So a stray TableName that names a throttled table may still be throttled against that table. This is not measured: 60 TransactGetItems naming a 1 RCU table all got 200, because the burst was not used up. With throttling on, a top-level TableName in a batch or transaction request throttles it against that table #1536 covers it and is not fixed here.
  • No other operation, PartiQL, TTL, batch path or storage backend is touched. The change is in the core crate's request types, shared by every backend.
  • Operators see a behaviour change only for clients that send the stray member, which used to fail. No upgrade manual entry added.

Open PRs touching transaction.rs: #1249 reorders CancellationReason fields (near line 259), and #853 changes CancellationReason methods (near line 316). Both hunks are far from the two input types, so no text conflict is expected; neither was test-merged. #826 does not touch the file.

Testing done

Dev desktop, SQLite, release builds from the same target dir. The "main" binary is this branch with the two added members removed.

Check Result
cargo fmt --check clean
cargo +1.97.0 clippy -p extenddb-core --all-targets -- -D warnings clean
cargo test -p extenddb-core --lib transaction 13 passed
tests/test_transact_stray_table_name.py, 20 runs against the branch 20 of 20 runs, 6 passed each
same file against the main-equivalent build 4 failed, 2 passed
9 transaction and misc wire files (352 tests), branch 352 passed, 2 xfailed
same 9 files, main-equivalent build 352 passed, 2 xfailed

The 9 files: test_transaction_operations, test_transact_expression_validation, test_transact_update_remove_only, test_transact_token_return_fields, test_transaction_key_size_validation, test_partiql_transaction, test_transact_absent_item_isolation, test_misc_operations, test_transact_write_conflict.

PostgreSQL 16, release build, second review run:

Check Result
cargo +1.97.0 clippy --all-targets --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooks -- -D warnings clean
cargo +1.97.0 clippy --all-targets --features extenddb-engine/backup-test-hooks -- -D warnings clean
cargo +1.94.0 test -p extenddb-core --lib transaction (MSRV) 13 passed
test_transact_stray_table_name.py, test_transaction_operations.py, test_transact_expression_validation.py, test_misc_operations.py, 3 runs 80 passed each run
stray file with the change reverted 4 failed, 2 passed

The review also sent other unknown members beside TableName (Nope) and near names (tablename, tableName, TABLENAME, TableNames). All were refused with SerializationException on both operations.

Wire setup (SQLite): extenddb init --config <toml> --data-db <db>, extenddb serve --config <toml> --foreground, then from the repo root eval "$(python devtools/provision-test-credentials)" with EXTENDDB_TEST_ENDPOINT, EXTENDDB_ADMIN_USER and EXTENDDB_ADMIN_PASSWORD exported, then pytest tests/test_transact_stray_table_name.py from tests/.

Control: remove the two added members, run the unit test.

--- a/crates/core/src/types/transaction.rs
+++ b/crates/core/src/types/transaction.rs
@@ TransactGetItemsInput and TransactWriteItemsInput
-    #[serde(rename = "TableName", default)]
-    pub ignored_table_name: IgnoredAny,

Command: cargo test -p extenddb-core --lib transaction::tests. Result: a_top_level_table_name_of_any_type_is_ignored fails with TransactGetItems refused "t"; 7 passed, 1 failed. The tree was restored with git checkout -- crates and git status --short was empty.

The same patch built into the server gives the 4 wire failures in the table above.

Not run: Cassandra and MongoDB wire runs, and an MSRV build of the server crate (only the core crate changed).

Open questions

  • Has anyone measured on live DynamoDB that a top-level TableName of a wrong type (5, true, an object, a list, null) is ignored in these two operations? The issue lists those values as measured; the wire test sends them and expects the answer of the request without the member.
  • A body that sends TableName twice ("a", then 5) is now accepted with 200. Main refused it as an unknown field. What DynamoDB answers to a repeated member is not measured.

…actWriteItems

DynamoDB answers a TransactGetItems or TransactWriteItems request with a top-level TableName as the same request without it. ExtendDB refused it with SerializationException because both input types deny unknown members.

Both input types now accept a TableName of any JSON type and drop it. Any other unknown member is still refused. The table checks read only the members of TransactItems, so nothing else changes.

Refs #1535

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed at 9f18647. 1 finding: 1 Docs.

The change lets TransactGetItems and TransactWriteItems accept a top-level TableName of any JSON type and drop it, while other unknown top-level members are still refused. Confirmed: removing the two new members fails a_top_level_table_name_of_any_type_is_ignored (TransactGetItems refused "t", 12 passed, 1 failed); the refusal text for an unknown member lists TableName as the description says (unknown field Nope, expected one of TransactItems, TableName, ReturnConsumedCapacity``); the new wire file and test_transaction_operations.py pass on SQLite (37 passed); the head merged with the base tip (identical to the base SHA) passes `extenddb-core` and `extenddb-engine` tests (1262 and 985 unit tests, 0 failed); `cargo test -p extenddb-core --lib transaction` runs 13 tests, as the description says.

  • Docs crates/server/src/request_helpers.rs:41 — The doc on extract_table_name still says batch and transact operations carry no top-level TableName, which this change makes untrue for the two transact operations.

Docs — outside the diff

crates/server/src/request_helpers.rs:41
Docs
The doc comment at request_helpers.rs:40-43 says "Batch and transact operations embed table names in nested structures and carry no top-level TableName, so this returns None for them." After this change TransactGetItems and TransactWriteItems accept a top-level TableName, and extract_table_name (request_helpers.rs:46) returns it for them, so handler.rs:253 and request_helpers.rs:184 see a name.

Fix: reword the comment to say that a transact request may carry a stray TableName the engine ignores, and that the callers must not treat it as the table the request acts on. The PR body's throttling note (#1536) already says this is by code reading only.

Evidence: the line quoted above; the diff adds #[serde(rename = "TableName", default)] ignored_table_name to both input types (transaction.rs:25-27, :92-94) and TableName is accepted on the wire (37 SQLite wire tests passed).

@navareamol

Copy link
Copy Markdown
Collaborator Author

@LJMart11 Reworded the extract_table_name doc in 05bb5d3e9. It now says TransactGetItems and TransactWriteItems accept a stray top-level TableName that the engine ignores, that this function can return it for them, and that callers must not treat it as the table the request acts on. Comment only; cargo fmt --check -p extenddb-server is clean.

@navareamol
navareamol requested a review from LJMart11 December 4, 2026 18:36

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.

2 participants