Repository navigation
fix(core): ignore a top-level TableName in TransactGetItems and TransactWriteItems - #1579
navareamol wants to merge 2 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
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 onextract_table_namestill says batch and transact operations carry no top-levelTableName, 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).
|
@LJMart11 Reworded the |
What
TransactGetItems and TransactWriteItems now accept a top-level
TableNameof any JSON type and ignore it. Any other unknown top-level member is still refused with SerializationException. The refusal text for that member now listsTableNameamong the expected members, for example "expected one ofTransactItems,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:TransactGetItemsInputandTransactWriteItemsInputget aTableNamemember that deserializes intoserde::de::IgnoredAnyand is never read.Why
Refs #1535
Issue #1535 measures that DynamoDB answers a request with a top-level
TableNameas it answers the same request without it (19 values, missing table insideTransactItems). Both input types carry#[serde(deny_unknown_fields)](transaction.rslines 18 and 82 on main), soTableNamewas 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:
table_name_gate.rs,check_transact_items) and the cross-account check (cross_account.rs,batch_or_transaction) read only the members ofTransactItems. They never read the top-level member, so a strayTableNamegets no name or ARN checks, as the issue expects.handler.rsregisters and throttle-checksextract_table_name(&input)before the engine deserializes the request, on main and on this branch alike. So a strayTableNamethat 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.Open PRs touching
transaction.rs: #1249 reordersCancellationReasonfields (near line 259), and #853 changesCancellationReasonmethods (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.
cargo fmt --checkcargo +1.97.0 clippy -p extenddb-core --all-targets -- -D warningscargo test -p extenddb-core --lib transactiontests/test_transact_stray_table_name.py, 20 runs against the branchThe 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:
cargo +1.97.0 clippy --all-targets --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooks -- -D warningscargo +1.97.0 clippy --all-targets --features extenddb-engine/backup-test-hooks -- -D warningscargo +1.94.0 test -p extenddb-core --lib transaction(MSRV)test_transact_stray_table_name.py,test_transaction_operations.py,test_transact_expression_validation.py,test_misc_operations.py, 3 runsThe 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 rooteval "$(python devtools/provision-test-credentials)"withEXTENDDB_TEST_ENDPOINT,EXTENDDB_ADMIN_USERandEXTENDDB_ADMIN_PASSWORDexported, thenpytest tests/test_transact_stray_table_name.pyfromtests/.Control: remove the two added members, run the unit test.
Command:
cargo test -p extenddb-core --lib transaction::tests. Result:a_top_level_table_name_of_any_type_is_ignoredfails withTransactGetItems refused "t"; 7 passed, 1 failed. The tree was restored withgit checkout -- cratesandgit status --shortwas 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
TableNameof 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.TableNametwice ("a", then5) is now accepted with 200. Main refused it as an unknown field. What DynamoDB answers to a repeated member is not measured.