Skip to content

fix(engine): answer a missing TableName, Key or Item as DynamoDB does - #1262

Open
LeeroyHannigan wants to merge 6 commits into
mainfrom
fix/1108-missing-members
Open

LeeroyHannigan wants to merge 6 commits into
mainfrom
fix/1108-missing-members

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

What

A request without TableName, Key or Item, or with one of them as JSON null, now gets DynamoDB's ValidationException. Each missing member gets the clause Value null at '<path>' failed to satisfy constraint: Member must not be null, after 1 validation error detected: or 2 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_input takes 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 list tableName first, and PutItem and DeleteItem list it last.
  • null_clause builds one clause. require_members and Found::null of the PartiQL request checks call it, and this PR deletes NOT_NULL from partiql/request_checks.rs.
  • GetItem, PutItem, DeleteItem, UpdateItem, DescribeTable, DeleteTable, UpdateTable, Query and Scan read their input through read_input.
  • PutItem no longer checks a missing or null name on the raw body. Its read lists a missing Item beside a missing name.
  • CreateTable takes a null TableName out 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, UpdateTableInput and CreateTableInput in crates/core/src/types/table.rs read more members with a type:

  • SSESpecification must be a JSON object, on both inputs. The new json_object reader checks this, and the member stays a serde_json::Value.
  • UpdateTable reads ReplicaUpdates and GlobalTableWitnessUpdates as lists of objects, MultiRegionConsistency and GlobalTableSettingsReplicationMode as strings, and DisassociationProtectionEnabled as a boolean.
  • CreateTable reads ResourcePolicy, GlobalTableSettingsReplicationMode and GlobalTableSourceArn as strings.

Neither operation acts on these members. The public API reference gives the types of CreateTable's GlobalTableSettingsReplicationMode and GlobalTableSourceArn, and these two are not measured. The struct literals that list every member get the new members as None: 4 for UpdateTableInput and 12 for CreateTableInput. One of them is in production code, create_table_input_from_params in crates/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 key clause" stands for Value null at 'key' failed to satisfy constraint: Member must not be null.

Request DynamoDB ExtendDB on main (2ef5613)
GetItem, DescribeTable, DeleteTable, Query or Scan with "TableName": null 1 validation error detected: and the tableName clause SerializationException, invalid type: null, expected a string
UpdateTable, DescribeTable, DeleteTable, GetItem, Query or Scan without TableName the same SerializationException, missing field `TableName`
GetItem with "Key": null, PutItem with "Item": null the key or the item clause SerializationException, invalid type: null, expected a map
GetItem, DeleteItem or UpdateItem without Key, PutItem without Item the key or the item clause SerializationException, missing field `Key` or missing field `Item`
GetItem {} and UpdateItem {} 2 validation errors detected: , the tableName clause, then the key clause SerializationException, missing field `TableName`
PutItem {} 2 validation errors detected: , the item clause, then the tableName clause the tableName clause alone
DeleteItem {} 2 validation errors detected: , the key clause, then the tableName clause SerializationException
UpdateTable without TableName, with BillingMode BOGUS the tableName clause the enum clause at billingMode
CreateTable with "TableName": null The parameter 'TableName' is required but was not present in the request SerializationException, invalid type: null, expected a string

A member of the wrong JSON type gets a SerializationException on DynamoDB, ahead of a missing name. The measured rows are UpdateTable with SSESpecification of 5, "x" or [], ReplicaUpdates of 5, [5] or {}, and MultiRegionConsistency, GlobalTableWitnessUpdates or GlobalTableSettingsReplicationMode of 5, and DisassociationProtectionEnabled of "x". The same holds for PutItem with ReturnValues of 5, Scan with Limit of "x", and CreateTable with a null name and SSESpecification or ResourcePolicy of 5.

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.
  • After the merge of main at 3534c9e, core passed 1161 tests and engine 890. One engine test from main, 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-targets is 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 warnings and cargo +1.97.0 fmt --all -- --check are clean after both merges. The same clippy command with --no-default-features was clean after the first.
  • After the merge of main at 5252eda, core passed 1177 tests, with 1 ignored, and engine 934. Clippy on core and the engine with -D warnings, fmt, cargo check --workspace --all-targets and 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.rs and tests/test_missing_members.py hold the same 57 rows, one line a row.
  • Against ExtendDB on SQLite, 12 wire files passed 1011 tests, with 2 xfailed. The files are test_missing_members.py, test_item_operations.py, the five PartiQL and expression files, and test_continuous_backups.py, test_table_throughput_mode.py, test_wording_parity_validation.py, test_config_fields.py and test_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_detected call in validate_enum_fields. Both this PR and #468 added the envelope N validation errors detected: and changed crates/engine/src/lib.rs for it. #468 merged first, with the envelope as validation_errors_detected in core, so the next commit drops this PR's copy, validation_failure. The merge of 3534c9e takes main's import_export.rs: #1009 moved create_table_input_from_params to crates/engine/src/import_export/files.rs, and its CreateTableInput literal 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 no Key now expects the null Key clause in place of main's SerializationException. cargo test -p extenddb-wasm-adapter passes: 3 unit tests and the parity corpus. The merge of 5252eda takes main's query.rs, where #544 moved the enum checks of handle_query into query_key_values::validate_query_request_body, and keeps this PR's read_input after that call. This PR adds a conflict with these open PRs:

Two open PRs add a CreateTableInput literal that lists every member: #140 in crates/storage-tidb/src/backup_engine.rs and #591 in crates/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 as None.

Not in this PR, each in an open issue:

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 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.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
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 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 three things need a change before this merges.

  1. The branch conflicts with main in two files: crates/engine/src/partiql/request_checks.rs and crates/engine/src/partiql/test_context.rs. I merged main at 222d80a locally. In request_checks.rs I deleted both local constants and kept the AT_LEAST_ONE import from crate::request_limits. In test_context.rs I kept main's context body on crate::test_context::context_on. With that, fmt, clippy on core and the engine, cargo check --workspace --all-targets and the core, engine, server and wasm adapter tests pass. Main now has crate::test_context, so missing_members_tests.rs could use it directly, drop the partiql feature gate and leave partiql/test_context.rs as it is on main. The wasm check on this head failed on main's Instant type error, so the parity corpus change has not run on the wasm32 target yet.

  2. PutItem with no TableName now answers other faults first. Main answered the tableName clause ahead of everything. On this branch, a body with no name and ReturnValues: "ALL_NEW" answers ReturnValues can only be ALL_OLD or NONE, and an Item of {"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 of validate_put_delete_return_values and the item read, using require_members.

  3. Query still answers a missing name with serde's text when another check fails. With no TableName and Select: "BOGUS", Limit: 0 or a {"N": "abc"} value, the answer is SerializationException "missing field TableName", and "TableName": null with Select: "BOGUS" gives "invalid type: null, expected a string". This is the case the description says now gets the tableName clause. validate_query_request_body runs before read_input, and on a failed check shape_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 missing TableName error in shape_fault, then add a Query row with Select: "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.

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

2 participants