Repository navigation
refactor(engine): share the validation refusal header with the batch checks - #1215
LeeroyHannigan wants to merge 7 commits into
Conversation
BatchWriteItem refused a table with more than 25 write requests with a message that printed each request as the bare word WriteRequest. None of the answers measured on DynamoDB prints a request that way. On 2026-11-20 DynamoDB answered all 18 sends of five such requests in this form: 1 validation error detected: Value at 'RequestItems.<table>.member' failed to satisfy constraint: Member must have length less than or equal to 25 It counted one error for each table over the limit, up to 10 errors. It listed two such tables in either order. It gave the same form on 2026-11-14. Other answers on 2026-11-14 and 2026-11-16 quoted the request map. ExtendDB now names up to 10 tables over the limit, each at its member path. A table with no requests keeps its message. Fixes #1039.
The batch count check and the PartiQL request checks each wrote the "1 validation error detected:" or "N validation errors detected:" header of their refusals. validation_refusal in request_limits.rs now writes it for both, from the list of failed constraints. It lists at most MAX_PARTS of them, as Found::into_result did. per_table_count_error and Found::into_result call it, and their answers do not change. The import of request_limits is now in the use block of partiql/request_checks.rs.
The comment over OVER_LIMIT named 2026-11-14 and 2026-11-16 as the days when DynamoDB quoted the request map. On 2026-11-25 it quoted the map in every BatchWriteItem answer measured. The test accepts that form from DynamoDB, so only the comment changes.
demohan
left a comment
There was a problem hiding this comment.
The member-path form this branch answers is not what the service gives today. On 2026-11-27 in us-east-1, BatchWriteItem with more than 25 requests for a table was refused 287 times with no member-path answer: all 257 raw-JSON sends quoted the request map, 207 in full and 50 with object hashes, and all 30 boto3 sends used the hash form. With several tables, the service answers one clause that quotes every table, including tables under the limit, where this head answers one clause per table over 25. Main keeps the service's at 'requestItems' path and its Map value must satisfy constraint ending, which this head drops. The test comment records the quoted map in every answer of 2026-11-25 too, and against the service the dual-target test passes only through its QUOTED_MAP escape; with the escape removed it failed 2 of 2.
The count refusal still comes before authorization, the refusals the PR keeps for BatchGetItem, empty tables and PartiQL match the service exactly, SQLite and PostgreSQL answer alike on all 34 shapes, five mutations fail the new test, and fmt, clippy, the 1.91.1 check, 934 engine tests and 290 Python tests on each backend are clean. The branch conflicts with main in partiql/request_checks.rs since #1375, and the CI runs at this head were cancelled.
I will approve once the refusal follows the quoted-map form the service gives, and the parity corpus passes.
crates/wasm-adapter/parity/corpus.json:5586
cargo test -p extenddb-wasm-adapter --test parity fails at this head and passes at the merge-base; CI's cargo test --workspace runs it.
| Map value must satisfy constraint: [Member must have length less than or equal to 25, \ | ||
| Member must have length greater than or equal to 1]" | ||
| ), | ||
| (false, false) => format!( |
There was a problem hiding this comment.
This builds one member-path clause per table over 25. The service quotes the whole requestItems map in one clause, every table included, at 'requestItems', ending Map value must satisfy constraint, as main does; 287 of 287 refusals today had that shape (full map from raw JSON, object hashes from boto3).
There was a problem hiding this comment.
ab88126 puts back main's text: one clause at 'requestItems' that quotes the table, ending with Map value must satisfy constraint: [Member must have length less than or equal to 25, Member must have length greater than or equal to 1]. On 2 December in us-east-1 DynamoDB quoted the request map in all 42 BatchWriteItem count refusals of 21 request shapes, each sent twice. It gave no member path answer. With several tables it quotes every table in one clause, where main quotes the first table over 25 alone. #1234 gives that form in 8fd5f4e.
| .iter() | ||
| .filter(|(_, count)| count.is_some_and(|n| n > limit)) | ||
| .map(|&(table_name, _)| table_name) | ||
| .take(if get { 1 } else { MAX_PARTS }) |
There was a problem hiding this comment.
Optional. validation_refusal already caps the clauses, so this .take(MAX_PARTS) changes nothing: removing it alone leaves every test passing, and the 11-table row fails only with the inner cap removed. The comment at :75 still says the service prints each request as its bare type name, which #1039 found untrue.
There was a problem hiding this comment.
ab88126 removes the loop with the .take(MAX_PARTS): it puts back main's check of one table at a time. The comment on write_requests_repr now says that DynamoDB prints each request with its fields, or as object hashes on some sends. So the count of requests matches, and the text of each request does not.
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 21e0dbe.
Required — outside the diff
crates/wasm-adapter/parity/corpus.json:5586— Update or reconcile the parity corpus case atcorpus.json:5586:cargo test -p extenddb-wasm-adapter --test parityfails at this head (0 passed, 1 failed). The case 'BatchWriteItem with 26 requests on a table in another account' expects theValue '{...=[WriteRequest, ...]}' at 'requestItems'text and getsValue at 'RequestItems.<arn>.member'. CI'scargo test --workspaceruns this test, so it has to pass before merge.
#1375 moved AT_LEAST_ONE, MAX_CLIENT_REQUEST_TOKEN and length_constraint from partiql/request_checks.rs to request_limits.rs. This branch moved MAX_PARTS there too. The merge imports those three and validation_refusal from request_limits.rs, and request_checks.rs keeps neither AT_LEAST_ONE nor MAX_PARTS.
…sals DynamoDB quoted the whole request map in every BatchWriteItem count refusal measured on 25 Nov, 27 Nov, 30 Nov and 2 Dec 2026. It gave no member path answer on those days. The refusal of a table with more than 25 requests goes back to main's text. That text is one clause at 'requestItems' that quotes the table and ends with the Map value constraint. The parity corpus case with 26 requests on a table in another account passes again. The comment on write_requests_repr no longer says that the service prints each request as its type name. The wire test checks DynamoDB's text outside the quoted map byte for byte, and that the map names every table. It checks ExtendDB's text by equality.
ab88126 put back main's per_table_count_error, which wrote the "1 validation error detected:" header itself. After that, only the PartiQL checks called validation_refusal. The WebAssembly build has no partiql feature, so there MAX_PARTS and validation_refusal were dead code. The clippy step of the wasm workflow failed on them with -D warnings. per_table_count_error now writes its clause and calls validation_refusal, as 98d471c had it. Its answers do not change.
With ab88126 this PR changes no answer that a client sees. It keeps |
Changes since the last review
crates/engine/src/partiql/request_checks.rskeeps both imports fromrequest_limits, and the file keeps neitherAT_LEAST_ONEnorMAX_PARTS.crates/wasm-adapter/parity/corpus.json:5586passes again.per_table_count_errorcallvalidation_refusalagain, as 98d471c had it. After ab88126, only the PartiQL checks called it, so the WebAssembly build, which has nopartiqlfeature, failed its clippy step on dead code.What
With ab88126, this PR changes no answer that a client sees. It keeps two changes in
crates/engine:MAX_PARTSand the header of a validation refusal move frompartiql/request_checks.rstorequest_limits.rs, asvalidation_refusal. It writes1 validation error detected: <clause>for one clause andN validation errors detected: <clause>; <clause>for more, with the first 10 clauses.Found::into_resultin the PartiQL checks andper_table_count_errorin the batch count check call it, and their answers do not change. fix(engine): name every batch table outside its count limit as DynamoDB does #1234, fix(engine): list batch table faults after the table count clause #1268, fix(engine): refuse a batch table value of another type before counts #1285 and fix(engine): refuse a BatchGetItem table value with no Keys by path #1301 call it for their batch count refusals too.write_requests_reprno longer says that DynamoDB prints each request as its type name. DynamoDB prints each request with its fields, or as object hashes on some sends.test_batch_write_too_many_itemsintests/python/test_batch.pynow sends three measured BatchWriteItem refusals of one table and checks the message. Against ExtendDB it compares the full text. Against DynamoDB it compares the text outside the quoted map byte for byte and checks that the map names the table. The map text is not stable: DynamoDB prints each request with its fields on some sends and as object hashes on others.Why
On 20 November 2026 DynamoDB answered a BatchWriteItem table with more than 25 requests at its member path, and this PR first gave that form. On later days it quoted the request map again, as main does. These are its answers of 2 December in us-east-1, at 21:03 UTC, each request sent twice, on table names that do not exist:
1 validation error detected: Value '{<table>=[<26 requests>]}' at 'requestItems' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 25, Member must have length greater than or equal to 1]WriteRequest., 26 putsWith several tables, DynamoDB quotes every table of the request in one clause. Main quotes the first table over the limit alone. #1234 gives the form with every table.
Refs #1039
Testing done
At 26ca9c6:
cargo test -p extenddb-engine --lib: 978 passed.cargo test -p extenddb-wasm-adapter: 4 passed, theparitycorpus test among them.cargo +1.97.0 fmt --all -- --check, the two clippy commands of.github/workflows/clippy.ymlwith-D warningsonextenddb-core,extenddb-engineandextenddb-server,cargo +1.97.0 clippy -p extenddb-engine --lib --no-default-features -- -D warningsandcargo +1.94.0 check --all-targetson the same crates are clean.python3 -m pytest --collect-only -qcollects 7164 tests intestsand 683 intests/python, with no error.tests/python/test_batch.py,tests/test_batch_operations.pyandtests/test_batch_write_validation_order.pypassed 63 tests on SQLite and 63 on PostgreSQL, 18 of them intest_batch.py. On SQLite,tests/test_partiql_requests.py,tests/test_partiql_batch.pyandtests/test_partiql_transaction.pypassed 439 tests, with 2 expected failures.test_batch_write_too_many_itemspasses on each recorded send of the three rows of 2 December. It fails when the map leaves out the table, on the member path form and with a second clause.Line counts against main: production +41 -28, tests +79 -8.
This PR adds no conflict with an open PR. No other open PR changes
request_limits.rsortests/python/test_batch.py. This head merges with each open PR that changes another of its files with no conflict that the PR does not have with main already.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
Breaking changes
None.
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.