Repository navigation
fix(engine): answer a missing TableName, Key or Item as DynamoDB does - #1262
LeeroyHannigan wants to merge 6 commits into
Conversation
A request without TableName, Key or Item, or with one of them as JSON null, failed the typed read of the body. ExtendDB answered SerializationException with serde_json's text. DynamoDB answers ValidationException with "Value null at '<path>' failed to satisfy constraint: Member must not be null" for each missing member. read_input in crates/engine/src/lib.rs takes a null required member out of the body before the read. It maps serde's missing field error to those clauses, in the operation's order. GetItem and UpdateItem list tableName first, and PutItem and DeleteItem list it last. null_clause builds each clause, and the PartiQL request checks call it too. GetItem, PutItem, DeleteItem, UpdateItem, DescribeTable, DeleteTable, UpdateTable, Query and Scan read their input through it. UpdateTable answers a missing name ahead of a BillingMode outside its set. PutItem no longer checks a missing name on the raw body, and its read lists a missing Item beside it. CreateTable gives a null name the text of an absent one. At the read, a member of the wrong JSON type answers SerializationException ahead of a missing member. The measured Scan, PutItem, UpdateTable and CreateTable requests show that DynamoDB does the same. A check that runs before the read, such as an enum check, still answers first. UpdateTable and CreateTable now read SSESpecification as an object. UpdateTable reads ReplicaUpdates, MultiRegionConsistency and GlobalTableWitnessUpdates for their JSON types, and does not act on them. It reads GlobalTableSettingsReplicationMode and DisassociationProtectionEnabled, which the API reference lists, the same way. CreateTable reads ResourcePolicy the same way. It also reads GlobalTableSettingsReplicationMode and GlobalTableSourceArn, which the API reference lists. DynamoDB's answers were measured in us-east-1 on 17, 18 and 20 Nov 2026. Each request went out twice with the same answer both times. Fixes #1108. Fixes #1219.
…nvelope require_members built the "N validation errors detected: " text with its own helper, validation_failure. Main now has the same envelope as extenddb_core::error::validation_errors_detected (#468), which validate_enum_fields calls after the merge of main. require_members calls it too, and validation_failure goes.
Main's #1009 moved `create_table_input_from_params` from `crates/engine/src/import_export.rs` to `crates/engine/src/import_export/files.rs`. The merge takes main's `import_export.rs`, and the `CreateTableInput` literal in `files.rs` gets the three members this branch adds to the type, as `None`.
The WebAssembly parity corpus that #1009 added records ExtendDB's answers. Its case for GetItem with a TableName outside the pattern and no `Key` expected main's SerializationException for the missing field. This branch answers a missing `Key` with DynamoDB's clause, `1 validation error detected: Value null at 'key' failed to satisfy constraint: Member must not be null`, so the case now expects that answer. DynamoDB also reports the table name fault in the same message (#1248); ExtendDB reports the missing member alone.
DynamoDB answers SerializationException to an UpdateTable whose ReplicaUpdates list holds a string (measured 25 Nov 2026, us-east-1). UpdateTableInput read each element as any JSON value, so ExtendDB accepted the list and answered the "At least one of" text. Now it reads each element as a JSON object, the element type that #1262 gives the same member, and the read refuses the string.
#544 moved the enum checks of handle_query into query_key_values::validate_query_request_body, which runs before typed deserialization. The merge takes that call from main and keeps this branch's read_input, which answers a missing TableName before the other members.
navareamol
left a comment
There was a problem hiding this comment.
I think three things need a change before this merges.
-
The branch conflicts with main in two files:
crates/engine/src/partiql/request_checks.rsandcrates/engine/src/partiql/test_context.rs. I merged main at 222d80a locally. Inrequest_checks.rsI deleted both local constants and kept theAT_LEAST_ONEimport fromcrate::request_limits. Intest_context.rsI kept main'scontextbody oncrate::test_context::context_on. With that, fmt, clippy on core and the engine,cargo check --workspace --all-targetsand the core, engine, server and wasm adapter tests pass. Main now hascrate::test_context, somissing_members_tests.rscould use it directly, drop thepartiqlfeature gate and leavepartiql/test_context.rsas it is on main. Thewasmcheck on this head failed on main'sInstanttype error, so the parity corpus change has not run on the wasm32 target yet. -
PutItem with no
TableNamenow answers other faults first. Main answered thetableNameclause ahead of everything. On this branch, a body with no name andReturnValues: "ALL_NEW"answersReturnValues can only be ALL_OLD or NONE, and anItemof{"pk": {"SS": []}},{"pk": {}},{"pk": {"S": "a", "N": "1"}}or{"pk": {"NULL": false}}answers the item text. The same happens with"TableName": null. None of these bodies is in the measured table and no test pins the order, so a test passes either way. Has anyone sent these to DynamoDB? If it answers the missing name first, I think PutItem needs a name check ahead ofvalidate_put_delete_return_valuesand the item read, usingrequire_members. -
Query still answers a missing name with serde's text when another check fails. With no
TableNameandSelect: "BOGUS",Limit: 0or a{"N": "abc"}value, the answer isSerializationException"missing fieldTableName", and"TableName": nullwithSelect: "BOGUS"gives "invalid type: null, expected a string". This is the case the description says now gets thetableNameclause.validate_query_request_bodyruns beforeread_input, and on a failed checkshape_fault_first::<QueryInput>reads the raw body, where a missing or null name is a serde fault. One option: take null members of the required list out of the body before that read and skip a missingTableNameerror inshape_fault, then add a Query row withSelect: "BOGUS"and no name to both test files once its answer is measured.
Two questions, not conditions. UpdateTable with "TableName": null, BillingMode: "BOGUS" and SSESpecification: 5 answers the tableName clause here, while SSESpecification: 5 alone answers SerializationException. Was that combination measured? The new .or_else also puts the name ahead of a bad TableThroughputMode; was that one measured, or only BillingMode?
I will approve once the branch merges cleanly with main and CI is green on the new head including wasm, PutItem's order for the bodies in point 2 is measured and matched, and Query answers a missing name the same way when another check fails.
What
A request without
TableName,KeyorItem, or with one of them as JSON null, now gets DynamoDB's ValidationException. Each missing member gets the clauseValue null at '<path>' failed to satisfy constraint: Member must not be null, after1 validation error detected:or2 validation errors detected:. Before this change, most of these requests failed the typed read of the body, and ExtendDB sent a SerializationException with serde_json's text.The change in
crates/engine/src/lib.rs:read_inputtakes a JSON null required member out of the body before the typed read. It maps serde's missing field error to the clauses, in the operation's order. GetItem and UpdateItem listtableNamefirst, and PutItem and DeleteItem list it last.null_clausebuilds one clause.require_membersandFound::nullof the PartiQL request checks call it, and this PR deletesNOT_NULLfrompartiql/request_checks.rs.read_input.Itembeside a missing name.TableNameout of the body before its read. So a null name gets the text of an absent one:The parameter 'TableName' is required but was not present in the request.At the read, a member of the wrong JSON type still gets a SerializationException, ahead of a missing member. DynamoDB answers the same way. For this,
UpdateTableInputandCreateTableInputincrates/core/src/types/table.rsread more members with a type:SSESpecificationmust be a JSON object, on both inputs. The newjson_objectreader checks this, and the member stays aserde_json::Value.ReplicaUpdatesandGlobalTableWitnessUpdatesas lists of objects,MultiRegionConsistencyandGlobalTableSettingsReplicationModeas strings, andDisassociationProtectionEnabledas a boolean.ResourcePolicy,GlobalTableSettingsReplicationModeandGlobalTableSourceArnas strings.Neither operation acts on these members. The public API reference gives the types of CreateTable's
GlobalTableSettingsReplicationModeandGlobalTableSourceArn, and these two are not measured. The struct literals that list every member get the new members asNone: 4 forUpdateTableInputand 12 forCreateTableInput. One of them is in production code,create_table_input_from_paramsincrates/engine/src/import_export/files.rs.Fixes #1108
Fixes #1219
Why
DynamoDB's answers, measured in us-east-1 on 17, 18 and 20 November 2026. Each request went out twice and got the same answer both times. "The
keyclause" stands forValue null at 'key' failed to satisfy constraint: Member must not be null."TableName": null1 validation error detected:and thetableNameclauseinvalid type: null, expected a stringTableNamemissing field `TableName`"Key": null, PutItem with"Item": nullkeyor theitemclauseinvalid type: null, expected a mapKey, PutItem withoutItemkeyor theitemclausemissing field `Key`ormissing field `Item`{}and UpdateItem{}2 validation errors detected:, thetableNameclause, then thekeyclausemissing field `TableName`{}2 validation errors detected:, theitemclause, then thetableNameclausetableNameclause alone{}2 validation errors detected:, thekeyclause, then thetableNameclauseTableName, withBillingModeBOGUStableNameclausebillingMode"TableName": nullThe parameter 'TableName' is required but was not present in the requestinvalid type: null, expected a stringA member of the wrong JSON type gets a SerializationException on DynamoDB, ahead of a missing name. The measured rows are UpdateTable with
SSESpecificationof5,"x"or[],ReplicaUpdatesof5,[5]or{}, andMultiRegionConsistency,GlobalTableWitnessUpdatesorGlobalTableSettingsReplicationModeof5, andDisassociationProtectionEnabledof"x". The same holds for PutItem withReturnValuesof5, Scan withLimitof"x", and CreateTable with a null name andSSESpecificationorResourcePolicyof5.ExtendDB on main at 2ef5613 gave DynamoDB's answer for 6 of the first 49 requests. With this change, 35 of the 49 get it, and 58 of all 80 measured requests. A SerializationException counts as DynamoDB's answer by its type alone, because #1012 holds the text of a member of the wrong JSON type.
Testing done
cargo test -p extenddb-core --lib: 1146 passed.cargo test -p extenddb-engine --lib: 886 passed, after the merge of main at 018715e.backup::tests::a_healthy_store_makes_create_backup_store_backed, failed once in the full run and passed when run alone 5 of 5.cargo check --workspace --all-targetsis clean after both merges. It compiles the struct literals in the Cassandra, MongoDB and PostgreSQL test targets, which need a live database to run.cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean after both merges. The same clippy command with--no-default-featureswas clean after the first.-D warnings, fmt,cargo check --workspace --all-targetsand an engine build without default features are clean. The WebAssembly adapter passed its 3 tests and the parity corpus.crates/engine/src/missing_members_tests.rsandtests/test_missing_members.pyhold the same 57 rows, one line a row.test_missing_members.py,test_item_operations.py, the five PartiQL and expression files, andtest_continuous_backups.py,test_table_throughput_mode.py,test_wording_parity_validation.py,test_config_fields.pyandtest_backup_restore_fidelity.py.Line counts over main after the merges: production +131 -40, tests +345. The production count includes the 3 changed lines of the parity corpus.
This PR holds three merges of main. The merge of 018715e took main's
validation_errors_detectedcall invalidate_enum_fields. Both this PR and #468 added the envelopeN validation errors detected:and changedcrates/engine/src/lib.rsfor it. #468 merged first, with the envelope asvalidation_errors_detectedin core, so the next commit drops this PR's copy,validation_failure. The merge of 3534c9e takes main'simport_export.rs: #1009 movedcreate_table_input_from_paramstocrates/engine/src/import_export/files.rs, and itsCreateTableInputliteral gets the three new members there. After it, ef2c7aa updates one case of the WebAssembly parity corpus (crates/wasm-adapter/parity/corpus.json, from #1009). The case of GetItem with a TableName outside the pattern and noKeynow expects the nullKeyclause in place of main's SerializationException.cargo test -p extenddb-wasm-adapterpasses: 3 unit tests and the parity corpus. The merge of 5252eda takes main'squery.rs, where #544 moved the enum checks ofhandle_queryintoquery_key_values::validate_query_request_body, and keeps this PR'sread_inputafter that call. This PR adds a conflict with these open PRs:crates/engine/src/query.rs, and fix(scan): check the numbers in ExpressionAttributeValues as the service does #562, fix(scan): report every Limit, Segment and TotalSegments range fault in the service's two forms #850, fix(scan): check AttributesToGet, ScanFilter, ExclusiveStartKey and ExpressionAttributeValues in the service's order #854 and fix(engine): send the ConditionalOperator enum text alone on Query and Scan #1100, inquery.rsandscan.rs. Each PR has its own read or check next to theread_inputline. On a rebase, keep both.crates/engine/src/delete_item.rsandcrates/engine/src/update_item.rs. fix(core): give a set with duplicate members DynamoDB's text #1368 passes the error of the read throughcrate::single_write_refusal. On a rebase, giveread_inputfix(core): give a set with duplicate members DynamoDB's text #1368's mapping:crate::read_input(body, &["Key", "TableName"], |e| crate::single_write_refusal(crate::deserialize_error(e)))in DeleteItem, and the same with&["TableName", "Key"]in UpdateItem.crates/engine/src/put_item.rs. fix(expression): operator cap, syntax error wording, PutItem map keys #558 gives PutItem's readcrate::deserialize_error. On a rebase, writecrate::read_input(body, &["Item", "TableName"], crate::deserialize_error).put_item.rs. Both change the string name check, and the comment of a branch that this PR deletes. On a rebase, keep theirvalidate_item_table_name(table_name, &ctx.limits)?and drop bothelse ifbranches.crates/engine/src/create_table.rs. fix(tagging): validate tag keys and values against the service grammar #485 reads the body once, at the top of the handler, asparsed. On a rebase, keep fix(tagging): validate tag keys and values against the service grammar #485's read and put this PR'scrate::drop_null_members(&mut body, &["TableName"])before it.table.rs,create_table.rs,update_table.rsand four storage test files. All three addreplica_updatestoUpdateTableInputasOption<Vec<serde_json::Value>>. This PR reads it as a list of objects, because DynamoDB refuses[5]. The PR that merges second drops its copy and keeps the list of objects. Increate_table.rsandupdate_table.rs, keep both sides: this PR's null name drop andread_inputcall, and theirEnumFaultschecks.crates/wasm-adapter/parity/corpus.json, on the case of GetItem with noKey. Both move the text check of that case to/Message. On a rebase, keep this PR's case: its ValidationException text stays undermessage.crates/engine/src/partiql/request_checks.rs. fix(engine): check a ClientRequestToken as DynamoDB does #1375 movesAT_LEAST_ONEtocrate::request_limits, and this PR replacesNOT_NULLwithcrate::null_clause. On a rebase, delete both local constants and keep fix(engine): check a ClientRequestToken as DynamoDB does #1375's import.Two open PRs add a
CreateTableInputliteral that lists every member: #140 incrates/storage-tidb/src/backup_engine.rsand #591 incrates/storage-cassandra/tests/direct/consistent_read.rs. They have no conflict in the text, but they stop compiling once this PR merges. Each literal needs the three new members asNone.Not in this PR, each in an open issue:
ConsistentReadof"yes"beside a missing member (A boolean member given as a JSON string is read differently from the service #984).SSESpecificationobject and no other change (UpdateTable does not read SSESpecification and refuses it as a request that names no change #1054). DynamoDB counts the member as a change and looks up the table. ExtendDB refuses the request as one that changes nothing.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
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.