Skip to content

fix(engine): list batch table faults after the table count clause - #1268

Open
LeeroyHannigan wants to merge 5 commits into
fix/1205-batch-count-member-pathsfrom
fix/1233-batch-count-and-tables
Open

LeeroyHannigan wants to merge 5 commits into
fix/1205-batch-count-member-pathsfrom
fix/1233-batch-count-and-tables

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

A BatchWriteItem with more than 25 tables, or a BatchGetItem with more than 100, can also hold a table with no request or too many. The ValidationException now lists the table count clause first, then the table faults, as DynamoDB does. Before this change, ExtendDB answered the table count clause alone.

  • BatchWriteItem gets at most two clauses, and each quotes the whole request map. The first is Value '{<map>}' at 'requestItems' failed to satisfy constraint: Member must have length less than or equal to 25. Then one clause 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] covers all tables with no request or more than 25.
  • BatchGetItem gets Value at 'RequestItems' failed to satisfy constraint: Member must have length less than or equal to 100, then a clause at RequestItems.<table>.member.Keys for each table with no key or more than 100, 10 clauses at most in all.

In check_batch_counts in crates/engine/src/request_limits.rs, the table count clause and the table faults are one refusal. quoted_refusal takes a list of constraints. A request within the table count gets the same answer as on #1234.

The base of this PR is #1234, which changes the same functions.

Why

DynamoDB's answers in us-east-1, each request sent twice, on table names that do not exist. Every other table of a request holds one request or one key. The BatchWriteItem rows are from 2 December 2026 at 21:03 UTC. The BatchGetItem rows are from 20 November, and the review of 30 November found the same BatchGetItem answers.

Request DynamoDB ExtendDB on #1234
BatchWriteItem, 26 or 30 tables, one with no request the table count clause, then the Map value clause the table count clause alone
BatchWriteItem, 26 tables, 9 or 10 with no request the same two clauses the table count clause alone
BatchWriteItem, 26 tables, one with no request and one with 26 the same two clauses the table count clause alone
BatchGetItem, 101 tables, one with no key the table count clause, then that table the table count clause alone
BatchGetItem, 101 tables, 9 with no key the table count clause, then the 9 tables the table count clause alone
BatchGetItem, 101 tables, 10 or 11 with no key the table count clause, then 9 of those tables the table count clause alone
BatchGetItem, 101 tables, one with no key and one with 101 the table count clause, then both tables the table count clause alone

DynamoDB changed the order of the BatchGetItem table clauses from one send to the next. Past 9 failed tables, it named another 9 on each send. ExtendDB names the first 9 in the order of its parsed request map, which is one of DynamoDB's answers.

With this change, ExtendDB gives each row DynamoDB's clauses. In the BatchWriteItem rows, the quoted map lists the tables in name order and prints each request as WriteRequest, as on #1234.

Fixes #1233

Testing done

At 5d597db, whose tree is the tree of 5559914:

  • cargo test -p extenddb-engine --lib: 979 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 7182 tests in tests and 701 in tests/python, with no error.
  • The new rows are in the existing tables: batch_count_refusals_name_each_path in request_limits.rs, and test_batch_write_too_many_items and test_batch_get_too_many_keys in tests/python/test_batch.py.
  • 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 81 tests on SQLite and 81 on PostgreSQL, 36 of them in test_batch.py.
  • This head's test_batch.py against a server built from fix(engine): name every batch table outside its count limit as DynamoDB does #1234's head: 9 failed and 27 passed. The 9 failures are its new rows.
  • The DynamoDB branch of test_batch_write_too_many_items passes on each recorded send of 2 December of its 14 rows. It fails when a map leaves out a table, on the member path form and with a wrong number of clauses.

Line counts against #1234: production +39 -30, tests +144 -60.

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.

Not in this PR:

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

A batch over its table count can also hold a table outside its own count. It gets the table count clause and the table faults in one answer, as the What section says. A client that matches the old text sees the new one. Requests within the table count get the same answers as before.


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 BatchWriteItem with more than 25 tables, or a BatchGetItem with more
than 100, got the table count clause alone. DynamoDB lists the table
count clause first, then each table with no request or too many. One
refusal lists at most 10 clauses, the table count clause among them.
DynamoDB listed the tables in a different order from one send to the
next.

`check_batch_counts` now puts the table count first in the list of
failed counts, so one refusal names both. The header counts the
clauses that the refusal lists. A request within the table count gets
the same answer as before.

Measured in us-east-1 on 20 November 2026, each request sent twice,
with names of tables that do not exist.

Fixes #1233.
…-tables

count_error keeps this branch's paths and passes its clauses to
validation_refusal, which now writes the header. The comment over CLAUSE
keeps this branch's text with the dates of the quoted answers.
One BatchWriteItem of 26 tables named one table by the ARN of another
account and gave another table no request. DynamoDB answered with the
table count clause, then the clause of the table with no request
(measured 2026-11-20). The server reads the ARN in its cross-account
check, so only a wire row reaches that path.

The new row of test_batch_write_too_many_items names one table by a
table ARN in account 000000000000 and expects that answer.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
type_fault kept the table count clause only for the strings "true" and
"false" where a boolean goes. Over the table count, DynamoDB answered
the count clause for a ConsistentRead of "TRUE", "True", "1", "yes",
"FALSE" or "0" too. Its echo of each request read the string as a
boolean (measured 2026-11-25). Before this change, those requests got a
SerializationException, where #1268 gave the count clause.

type_fault now keeps the count clause for each string that
reads_as_boolean accepts. That function reads BOOLEAN_TEXTS, the list
of strings that the Query shape check already uses, and
shape_fault_first calls it too. Another string, such as "x", keeps the
SerializationException, as DynamoDB answered on 2026-11-21.

The unit table and the wire table get rows for "TRUE", "1", "false" and
"x". Against DynamoDB, the wire table now accepts a table count clause
that quotes the request map, as DynamoDB gave on 2026-11-21 and
2026-11-25. Against ExtendDB it still compares the full text.

Refs #1266.
@demohan demohan self-assigned this Nov 29, 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.

BatchGetItem's table faults follow the table count clause as on the service at 82e3501, and BatchWriteItem's do not. With 42 shapes sent twice to us-east-1 and to this head and its base on SQLite and PostgreSQL, the two backends agree everywhere; on BatchGetItem (101 or 150 tables with empty ones, tables over 100 keys, an ARN of another account, a short name) this head matches both of the service's answers on every shape, one byte for byte, where the base matched 2 of 14, and the service named a different 9 of 10 tables on each send, as the cap here allows. On BatchWriteItem the service answered all 42 over-count requests in the quoted request-map form, at most two clauses (the quoted count clause, then one map-value clause for every faulty table), and this head matches neither answer on any of the 21 shapes: for 26 tables with 9 empty it gives 10 member-path clauses where the service gives 2. That form comes from #1234, and our review of #1215 asks for the quoted form. The three mutations fail the unit test, all 10 new Python rows fail on a server with the base's early return, fmt, clippy, 934 engine tests, test_batch.py on both backends and the 1.91.1 check are clean, and every CI run at this head was cancelled. Onto main at 222d80a the only conflict is the base's in partiql/request_checks.rs; resolved, it passes 979 engine tests and answers as this head.

I will approve once BatchWriteItem's table faults follow the service's quoted form, and a table ARN of another account answers before the counts in BatchWriteItem.

Comment thread crates/engine/src/request_limits.rs Outdated
.then(|| ("RequestItems".to_owned(), tables.len()))
.into_iter()
.chain(tables.iter().filter_map(|&(t, count)| {
let n = count.filter(|&n| n == 0 || n > limit)?;

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.

For BatchWriteItem this lists one member-path clause per faulty table; the service gives the quoted count clause and then a single Map value must satisfy constraint clause covering every faulty table, on all 21 shapes twice. The nine-table cap here fits only the member-path form. BatchGetItem's form here is right.

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.

5559914, the merge of #1234's new head, gives BatchWriteItem that form. The quoted table count clause comes first, then one Map value must satisfy constraint clause that quotes the whole map for all faulty tables. DynamoDB gave those two clauses on 2 December, both sends, for 26 and 30 tables with an empty table. It gave them for 26 tables with 9 or 10 empty tables, and for an empty table beside a table of 26 too. The cap of nine table clauses stays for BatchGetItem only.

Comment thread tests/python/test_batch.py Outdated
(OTHER_ACCOUNT + p if i == 13 else p, r)
for i, (p, r) in enumerate(_writes(26, {5}))
],
[5],

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 row fails against the service 2 of 2: with a table ARN of another account among 26 BatchWriteItem tables, the service answers Invalid request! All tables in the request must be from a single account. before any count check, and the two-table variants get the same sentence; this head runs the counts first (cross_account.rs:324). BatchGetItem applies the counts first on the service, as here. With the QUOTED escape at line 195 removed, all 7 BatchWriteItem over-count rows fail against the service, twice, so they check nothing about its answer. The body's 871 engine and 36 Python tests are now 934 and 37.

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.

5559914 removes the row. On 2 December DynamoDB answered Invalid request! All tables in the request must be from a single account. for this request and for two smaller ones, both sends, before any count check. Main runs the counts first too: cross_account::refuse calls check_request_item_counts before it returns that sentence. So this PR did not change the order, and #1548 tracks it. The QUOTED escape is gone, and the body has the counts of this head.

…-tables

The base now refuses a BatchWriteItem outside its counts in the quoted
request map form, as DynamoDB answered on 25 Nov and 2 Dec 2026. Both
branches changed check_batch_counts and its tests. The merge keeps this
branch's order, the table count clause first and then the table faults,
in each operation's form:

- BatchGetItem keeps a member path clause for each table with no keys or
  more than 100, after the count clause, 10 clauses at most.
- BatchWriteItem gets at most two clauses, each quoting the whole request
  map. The table count clause comes first. Then one Map value clause
  covers all tables with no request or more than 25. DynamoDB gave these
  two clauses for 26 and 30 tables with empty tables. It gave them for
  26 tables with an empty table and one of 26 requests too.

quoted_refusal takes a list of constraints. The wire rows of this branch
expect both clauses, checked against DynamoDB with no escape for a
quoted answer. The row with a table ARN of another account goes. On 2
Dec DynamoDB answered that request with the single account sentence
before any count check, and main and this branch run the counts first.
…-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

Copy link
Copy Markdown
Collaborator Author

@demohan

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.

2 participants