Skip to content

refactor(engine): share the validation refusal header with the batch checks - #1215

Open
LeeroyHannigan wants to merge 7 commits into
mainfrom
fix/1039-batch-write-member-path
Open

LeeroyHannigan wants to merge 7 commits into
mainfrom
fix/1039-batch-write-member-path

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

  • f4ff7e8 merges main at 01556cf. The conflict with fix(engine): check a ClientRequestToken as DynamoDB does #1375 in crates/engine/src/partiql/request_checks.rs keeps both imports from request_limits, and the file keeps neither AT_LEAST_ONE nor MAX_PARTS.
  • ab88126 puts back main's BatchWriteItem count refusal. DynamoDB quoted the request map in every BatchWriteItem count refusal measured on 25, 27 and 30 November and on 2 December 2026. It gave no member path answer on those days. The parity corpus case at crates/wasm-adapter/parity/corpus.json:5586 passes again.
  • 26ca9c6 has per_table_count_error call validation_refusal again, as 98d471c had it. After ab88126, only the PartiQL checks called it, so the WebAssembly build, which has no partiql feature, 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:

test_batch_write_too_many_items in tests/python/test_batch.py now 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:

BatchWriteItem DynamoDB ExtendDB
one table, 25 puts and a nested 26th 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] the same text, with each request printed as WriteRequest
one table, 26 deletes the same form the same
a table name with a ., 26 puts the same form the same

With 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, the parity corpus test among them.
  • cargo +1.97.0 fmt --all -- --check, the two clippy commands of .github/workflows/clippy.yml with -D warnings on extenddb-core, extenddb-engine and extenddb-server, cargo +1.97.0 clippy -p extenddb-engine --lib --no-default-features -- -D warnings and cargo +1.94.0 check --all-targets on the same crates are clean.
  • python3 -m pytest --collect-only -q collects 7164 tests in tests and 683 in tests/python, with no error.
  • Against SQLite and PostgreSQL servers built from this head: tests/python/test_batch.py, tests/test_batch_operations.py and tests/test_batch_write_validation_order.py passed 63 tests on SQLite and 63 on PostgreSQL, 18 of them in test_batch.py. On SQLite, tests/test_partiql_requests.py, tests/test_partiql_batch.py and tests/test_partiql_transaction.py passed 439 tests, with 2 expected failures.
  • The DynamoDB branch of test_batch_write_too_many_items passes 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.rs or tests/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

  • 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

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.

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 demohan self-assigned this Nov 27, 2026

@demohan demohan 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.

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.

Comment thread crates/engine/src/request_limits.rs Outdated
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!(

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.

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).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread crates/engine/src/request_limits.rs Outdated
.iter()
.filter(|(_, count)| count.is_some_and(|n| n > limit))
.map(|&(table_name, _)| table_name)
.take(if get { 1 } else { MAX_PARTS })

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.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 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 21e0dbe.

Required — outside the diff

  1. crates/wasm-adapter/parity/corpus.json:5586 — Update or reconcile the parity corpus case at corpus.json:5586: cargo test -p extenddb-wasm-adapter --test parity fails at this head (0 passed, 1 failed). The case 'BatchWriteItem with 26 requests on a table in another account' expects the Value '{...=[WriteRequest, ...]}' at 'requestItems' text and gets Value at 'RequestItems.<arn>.member'. CI's cargo test --workspace runs 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.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
…-tables

#1215 now writes per_table_count_error with validation_refusal, and
the base merged it. No branch above #1215 has per_table_count_error,
so no file changes.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
…first

#1215 now writes per_table_count_error with validation_refusal, and
the base merged it. No branch above #1215 has per_table_count_error,
so no file changes.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
#1215 now writes per_table_count_error with validation_refusal, and
the base merged it. No branch above #1215 has per_table_count_error,
so no file changes.
@LeeroyHannigan LeeroyHannigan changed the title fix(engine): name BatchWriteItem tables over 25 requests by member path refactor(engine): share the validation refusal header with the batch checks Dec 3, 2026
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@demohan

  • The refusal: ab88126 puts back main's quoted map form. The reply in the thread on request_limits.rs has the measurement.
  • The parity corpus: cargo test -p extenddb-wasm-adapter passes at 26ca9c6, the parity test among its 4 tests.
  • The conflict with main: f4ff7e8 merges main at 01556cf. In partiql/request_checks.rs it keeps both imports from request_limits, and the file keeps neither AT_LEAST_ONE nor MAX_PARTS. The head merges main at b3510a9 with no conflict.

With ab88126 this PR changes no answer that a client sees. It keeps validation_refusal, which #1234 to #1301 call, the corrected comment and the wire rows.

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@LJMart11 ab88126 puts back main's BatchWriteItem count refusal, which DynamoDB gave again on 25, 27 and 30 November and on 2 December. The corpus case at corpus.json:5586 expects that text. cargo test -p extenddb-wasm-adapter passes at 26ca9c6, the parity test among its 4 tests.

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.

3 participants