Skip to content

fix(expressions): validate in the service's order, with its messages - #399

Open
LeeroyHannigan wants to merge 39 commits into
mainfrom
fix/transact-validation-order
Open

LeeroyHannigan wants to merge 39 commits into
mainfrom
fix/transact-validation-order

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

jcshepherd approved 2d137cc on 23 November. After that, 59 PRs merged into main, up to 44a7b79. Seven of them conflicted with this branch: #526, #765, #1009, #544, #1449, #1411 and #1087. Since the approval the branch has ten new commits. Six merge main, one fixes the WebAssembly build of main, two fix the engine tests after a merge, and one adds the upgrade manual entry:

#765 dropped the : FilterExpression is null suffix from the Scan values message. In a942b74, the Scan row of tests/test_expression_semantics.py with a ProjectionExpression and ExpressionAttributeValues now expects the message with no suffix. The service gave that request the same message on 2026-11-24, on a table that does not exist, two sends each. Known differences no longer lists this message.

At 5ee0b6d, cargo fmt --check is clean, and clippy with -D warnings is clean on extenddb-engine with and without its partiql feature, on extenddb-engine for wasm32-unknown-unknown with the WebAssembly job's clippy configuration, and on extenddb-wasm-adapter. At cdafc6f, both clippy commands of .github/workflows/clippy.yml with -D warnings are clean on the whole workspace. The core lib tests give 1174 passed and 1 ignored, and the engine lib tests give 900 passed. On a SQLite server built from cdafc6f, the eleven test files that this PR adds or changes and tests/test_error_message_key.py of main give 450 passed. Testing done gives the commands.

The Transactions section now lists the checks of each item in the order that this PR runs them. It also gives the order that the service measured for the two expressions of an Update.

Testing done gives the runs at edb464c, the head before beafa78. The first bullet above gives the gates at beafa78.

What

Issue #108 lists 106 requests whose response differs from Amazon DynamoDB. This change makes ExtendDB check expressions and transactions in the service's order. For the groups below, ExtendDB now returns the service's messages. Every expectation was measured against the service in us-east-1, on the dates that Testing done lists. Every new test file was run against the service before it was run against ExtendDB.

Semantic checks of expressions

After the grammar pass, the service walks the parsed expression once, in expression order. It checks each node after its operands. Then it checks overlapping paths, and then the unused names and values. The new validate_update_semantics and validate_condition_semantics in crates/core/src/expression/semantics/ follow that walk, with one file per rule family. The parsers now do grammar only. They keep function names as written and record the section order for the walk.

  • UpdateExpression: + and - take numbers, list_append takes lists, ADD takes a number or a set, and DELETE takes a set. ExtendDB refuses a placeholder of the wrong type with the service's type names. Operators and functions name S, N or L. ADD and DELETE name STRING, NUMBER, Binary, BOOL, NULL, LIST or MAP, and the message ends with the allowed set of the operator, typeSet: ALLOWED_FOR_ADD_OPERAND or typeSet: ALLOWED_FOR_DELETE_OPERAND (39ad6cd, measured 2026-11-16).
  • Function names are case-sensitive. IF_NOT_EXISTS(x, :v) and foo(x) get Invalid function name. A condition function gets not allowed in an update expression. ExtendDB refuses list_append as an operand of a function or of +. Both update functions take two operands, and the first operand of if_not_exists is a document path.
  • ExtendDB reports a repeated section after the actions of that section, so SET a = :v SET b = :q reports :q.
  • Before this change, ExtendDB accepted and wrote IF_NOT_EXISTS(x, :v), and it accepted DELETE s :string when s did not exist. ExtendDB already refused SET a = :string + :n when it evaluated the update (An operand in the update expression has an incorrect data type). It now refuses it before it reads the table, with the service's text.
  • ConditionExpression and FilterExpression: the six condition functions match only as written. Before this change, ExtendDB accepted and evaluated ATTRIBUTE_EXISTS(pk).
  • if_not_exists and list_append in a condition get not allowed in a condition expression. A boolean function in operand position, and size in condition position, get not allowed to be used this way.
  • Each condition function takes a fixed number of operands. attribute_exists and attribute_not_exists take a document path. begins_with takes a string or binary, and attribute_type takes a string that names a type. ExtendDB checks both at request time, with the prefix of the operation.
  • The unused names and values message lists every unused key in one sorted set, so the message is the same on every backend. Before this change it named one key in hash order, which differed between backends and processes.

Legacy conditions

ScanFilter, QueryFilter and KeyConditions bypass the expression parser. So they get their own request-time check, ahead of the desugaring and the table lookup. Its rules were measured against the service on 2026-10-23 for every ComparisonOperator and AttributeValue type. The check covers:

  • the operator name: Invalid comparison operator
  • the value count: Invalid number of argument(s) for the <op> ComparisonOperator
  • the type of the first value: ComparisonOperator <op> is not valid for <type> AttributeValue type
  • that every value has the type of the first value
  • that a BETWEEN lower bound is not above its upper bound

Each message has the One or more parameter values were invalid: prefix. ExtendDB refuses a range key operator that the service does not index (NE, NULL, NOT_NULL, CONTAINS, NOT_CONTAINS, IN) in KeyConditions with Attempted conditional constraint is not an indexable operation. Before this change, a ScanFilter with BEGINS_WITH and a number returned 200 on an empty table.

The BETWEEN bound check reads each bound with the number_value of main (#620), as comparison_number does (a0f2a6b). For a bound that the number check refuses, compare_orderable returns None, as it does for a value that is not a number. The range check then does not refuse the request.

Request stage on the read APIs

Query and Scan check the FilterExpression first. The KeyConditionExpression comes next, with its Invalid KeyConditionExpression: prefix and ahead of the key schema match, so an undefined #n gets the undefined name message. Query refuses a begins_with key condition value that is not an S or a B right after that parse. Then come the ProjectionExpression and the unused names and values. All of these come before the table lookup. Before this change, an undefined :q in a filter returned 200 on an empty table.

A function in a KeyConditionExpression gets a message that depends on its name:

  • contains, attribute_exists, attribute_not_exists and attribute_type get Invalid operator used in KeyConditionExpression, with no function name.
  • size gets KeyConditionExpressions cannot contain nested operations.
  • Any other name, Begins_With included, gets Invalid function name; function: <name>.

The message names the first undefined #name or :value in the text, whether a name or a value comes first. A Limit under 1 on Query and Scan gets 1 validation error detected: Value at 'Limit' failed to satisfy constraint: Member must have value greater than or equal to 1. That check comes ahead of the table lookup and every expression.

On Scan, the range checks on Segment and TotalSegments also come ahead of the expressions. The checks that the two go together, and that Segment is below TotalSegments, come after the expressions and the unused names and values. They come before the table lookup. #558, #562 and #850 hold their own copies of these Scan range checks, and #507 holds this copy through its merge of this branch. #850 has the service's texts for them. When one of these PRs merges, each PR that merges after it drops its own copy and uses the copy on main.

Single-item order

UpdateItem checks the whole ConditionExpression before the UpdateExpression. PutItem, UpdateItem and DeleteItem wrap every expression-stage error in 1 validation error detected: and omit the : ConditionExpression is null suffix. The read, batch and transaction APIs return the messages bare. The expression size: N suffix depends on the operation. A Scan FilterExpression and a transaction ConditionExpression have it, and a Query FilterExpression and the single-item ConditionExpression do not.

Eleven assertions in three existing dual-target test files expected the unprefixed text, and they fail against the service. There are 3 in test_expression_error_prefix.py, 6 in test_expression_param_usage.py and 2 in test_expression_size_limit.py. This PR fixes them and adds one assertion to the third file.

Legacy AttributeUpdates get a request-time check of the value types, ahead of the table lookup and the key checks. An ADD of a value that is not a number or a set gets 1 validation error detected: One or more parameter values were invalid: ADD action is not supported for the type S. An ADD of a list gets the same text with type L. The service passes that request to the table lookup (Known differences, item 13). A DELETE with a value that is not a set gets ... DELETE action with value is not supported for the type N. A ConditionCheck with an empty ConditionExpression gets Invalid ConditionExpression: The expression can not be empty;.

Transactions

TransactGetItems and TransactWriteItems check in phases, and each phase covers every item before the next phase starts. Before the table lookup, TransactWriteItems checks each item in turn:

  • the attribute name sizes, in the expression maps and in the item of a Put
  • the numbers in the ExpressionAttributeValues (for a Put or a Delete, only with a ConditionExpression), then in the key or in the item of a Put
  • the nesting of the ExpressionAttributeValues of the item (32 wrappers pass, 33 do not)
  • its expressions, the UpdateExpression before the ConditionExpression
  • the unused names and values
  • for a Put, the 400 KB item size and the item nesting

The service checks the ConditionExpression of an Update before its UpdateExpression, as UpdateItem does (measured 2026-11-12 and 2026-12-03). On 2026-10-14 it answered the UpdateExpression first. This PR keeps that order, and test_transaction_checks_the_update_first expects it. #597, which sits on this PR, checks the condition first in 617ab86.

Then come the table lookup and the 4 MB total. Then one pass over the items in order stops at the first failing item. It checks a key that does not fit the schema, then a key attribute named in an Update, then an empty key value. The first two give a cancellation with ValidationError on that item and None on every other item. The third gives a top-level ValidationException.

Duplicate targets come next. Last comes an Update that stores a value nested deeper than an item may hold, which gets a ValidationError reason on every such item. TransactGetItems checks the projections, then does the table lookup, then checks the key schema (first offending item only), and then checks for duplicate keys. As on the service, an undefined reference fails the request instead of giving a cancellation reason per item. A key schema mismatch leaves the conditions of the other items unevaluated.

TransactWriteItems returns "ItemCollectionMetrics": {} when the request asks for SIZE and no table has a local secondary index (LSI). The ConsumedCapacity entries of both transaction APIs are in table creation order, oldest first, as measured on the service (section below).

Key-shaped messages

GetItem, DeleteItem, UpdateItem, BatchGetItem and BatchWriteItem (Put and Delete) refuse a key with a missing, mistyped or extra attribute. The message is The provided key element does not match the schema. PutItem keeps Missing the key pk in the item and Type mismatch for key. BatchWriteItem returns "ItemCollectionMetrics": {} under SIZE with no LSI.

Table ARNs

Table Amazon Resource Names (ARNs) in TableName (eight #108 rows) stay unsupported by decision. An ExtendDB table ARN names the account and region of ExtendDB. So a table that streams or replicates to Amazon DynamoDB would answer to two ARNs. docs/differences-from-dynamodb.md records this. Open PR #200 takes the opposite position, and the two PRs need one decision before either merges.

PartiQL

ExecuteStatement runs a statement as the classic request above. So the statement gets the same refusals, without the expression prefix. The answers of main in this section come from a SQLite server built from 1d3be63. The answers of this branch come from a SQLite server built from 2d137cc plus the fix of Known differences item 13. That fix changes only the legacy AttributeUpdates path, which PartiQL does not use. The service's answers to these statements are not measured.

For example, SELECT * FROM "t" WHERE pk = 'k' AND attribute_type(b, 'XX') returned 200 with no items on main. On this branch it gets Invalid attribute type name found; type: XX, valid types: {S,SS,N,NS,B,BS,BOOL,NULL,L,M}. The diff also changes four PartiQL paths:

  • partiql::bare_expression_error also drops the 1 validation error detected: that UpdateItem now puts in front of an expression-stage message. So a statement keeps the text it had on main. UPDATE "t" SET a = 1 SET a = 2 WHERE pk = 'k' gets Two document paths overlap with each other; must remove or rewrite one of these paths; path one: [a], path two: [a] on both.
  • partiql/item_depth.rs handles an UPDATE that sets a value 32 levels deep. It now checks the whole condition, syntax and then semantics, before the update expression, as UpdateItem does. With a 32-level ?, UPDATE "t" SET a = ? WHERE pk = 'k' AND attribute_type(b, 'XX') got ConditionalCheckFailedException on main. It now gets a ValidationException with the Invalid attribute type name found text above. In ExecuteTransaction, main cancelled the same statement with ConditionalCheckFailed. This branch answers a ValidationException Invalid ConditionExpression: Invalid attribute type name found; ..., with the prefix, with or without the 32-level value.
  • partiql/base_join.rs handles a read of an LSI that reads each item back from the table. It now runs the semantic pass on its filter before it reads the index. SELECT b FROM "t"."lsi" WHERE pk = 'k' AND attribute_type(lk, 'XX') returned 200 with no items on main. It now gets the Invalid attribute type name found text.
  • The test in partiql/batch.rs now expects UPDATE "t" SET a = list_append(l, 1) WHERE pk = 'k' to translate. UpdateItem refuses it when the statement runs. ExecuteStatement now answers Incorrect operand type for operator or function; operator or function: list_append, operand type: N. On main it answered An operand in the update expression has an incorrect data type. In BatchExecuteStatement the statement gets the same two texts as a ValidationError.

Commits

This is one PR with three pieces that can be read on their own:

  • The legacy condition validator is in aef6e1b, 475465a and 90fdc32: legacy_filter.rs, legacy_filter_tests.rs, and the 79 wire cases in tests/test_expr_operand_type_and_size.py.
  • The ConsumedCapacity order is in 68dcd0a, 217b5f9 and b7ba331. These commits add the creation_date_time field on TableKeyInfo and the column read in the SQLite, PostgreSQL and Cassandra storage crates. They also add the MongoDB catalog write that keeps milliseconds, and tests/test_transact_capacity_order.py.
  • The decision to keep table ARNs in TableName unsupported is one row in docs/differences-from-dynamodb.md, added in 29229c2 with the semantic pass.

Commits ac76c66 and 964f3c3 only move code: the semantic pass split by rule family, and the update parser tests into their own file. The six commits from af5f681 to cbb04f0 change the transaction phases, the Query key condition checks, four request stage texts and the Scan parameter order. They add tests for each.

The commits after 1454cc9:

  • 7e04892 sets creation_date_time in two TableKeyInfo literals that main added in test code.
  • a0f2a6b reads the BETWEEN bounds with number_value (Legacy conditions above).
  • 39ad6cd names the DELETE typeSet for a DELETE operand of the wrong type.
  • 2e1fa32 passes max_expression_depth to the update section parse in parse_update_expr_checked. So UpdateItem, TransactWriteItems and the PartiQL item depth check keep the depth limit of fix(core): bound the nesting depth of update expressions #1000.
  • 29f6669 adds depth tests that nest 50,000 calls of a name the service does not define, in a condition and in an update. Since cd50250 they expect the name refusal.
  • cd50250 refuses a call by name past the depth limit (next section).

Why

Refs #108. This PR fixes some of its groups, and the list below gives the groups that remain.

A client that maps on the error codes and messages of the service saw different responses from ExtendDB on these requests. So did a client that reads CancellationReasons, ItemCollectionMetrics or ConsumedCapacity. ExtendDB also accepted request shapes that the service refuses:

  • a function name in the wrong case
  • a DELETE of a string on an absent attribute
  • a repeated update section
  • overlapping update paths
  • a nested list_append
  • an if_not_exists whose first operand is not a path

On 2026-10-14, before the legacy condition work above, this branch was measured on the 106 rows in #108. It returned the status, error type and message of the service for 83 rows, and main did so for 30. The rows that remained are in these groups:

  • the syntax wording of the parser (Syntax error; token: X, near: Y, 13 rows)
  • the ResourceNotFound message text (3 rows)
  • 5 of the 8 rows that name a table ARN, unsupported by decision
  • the rendering of an over-limit list value in the 1 validation error detected message of the service (2 rows: 101 transaction items, 26 batch writes)

The 4 MB transaction message also remains: the text of the service carries its own serialized payload size.

ConsumedCapacity order per backend

TransactGetItems and TransactWriteItems return one ConsumedCapacity entry per table, in table creation order, oldest first. Two tables with the same stored creation time come in name order.

The precision of the stored creation time differs per backend, so the point at which two creates tie differs with it:

  • SQLite: about 0.24 microseconds. The catalog text carries nanosecond digits, and the value the order uses is an f64 of epoch seconds.
  • PostgreSQL: microseconds, from a TIMESTAMPTZ column.
  • MongoDB: milliseconds. The catalog write used to drop the sub-second part, so two tables created inside one second tied and the array came back in name order. A catalog row written before that fix keeps whole seconds and still ties.
  • Cassandra: milliseconds, from a CQL timestamp column.

The order was measured on SQLite, PostgreSQL and MongoDB. The six cases of tests/test_transact_capacity_order.py run in CI on SQLite, PostgreSQL, MongoDB and Cassandra. At 2d137cc they passed on all four backends.

Known differences

Items 1 to 8 are differences from the service on the legacy condition paths that this PR does not change. They were measured against the live service on 2026-10-23 and filed as #477. Since #429, main answers items 5 and 7 with the message of the service for the key attributes of a table. The other six are present on main.

  1. Two legacy condition entries that are both invalid: the service names the second entry in map order, and ExtendDB names the first.
  2. Query with a QueryFilter on a primary key attribute: the service refuses it, and ExtendDB returns 200.
  3. ScanFilter EQ with an N AttributeValue whose value is not a number: the service reports the numeric conversion, and ExtendDB returns 200.
  4. ScanFilter BEGINS_WITH with an N AttributeValue whose value is not a number: the service reports the numeric conversion first. ExtendDB reports the operator and type message (ComparisonOperator <op> is not valid for <type> AttributeValue type).
  5. KeyConditions on the sort key with a value of a valid type other than the schema type: the service gives the schema type message. ExtendDB answered HTTP 500 before fix(query): classify and order key conditions on a multi-attribute GSI the way the service does #429.
  6. KeyConditions EQ or BEGINS_WITH with an empty string: the service refuses it, and ExtendDB returns 200.
  7. KeyConditions EQ on an S partition key with an N value: the service refuses it with the schema type message. ExtendDB returned 200 before fix(query): classify and order key conditions on a multi-attribute GSI the way the service does #429.
  8. BatchGetItem with ReturnConsumedCapacity TOTAL where every key is absent: the service returns one entry per table, and ExtendDB returns an empty list.

Items 9 to 12 were measured against the live service on 2026-10-27 and are present on main.

  1. An empty ConditionExpression on a transaction Put, Delete or Update, and on PutItem, UpdateItem or DeleteItem: the service answers Invalid ConditionExpression: The expression can not be empty;. ExtendDB treats it as no condition.
  2. An attribute name over the limit: the service answers Attribute name is too large, must be less than 65536 bytes, and ExtendDB words it differently. The boundary agrees.
  3. Scan Segment and TotalSegments range checks: the service answers Value at 'TotalSegments' failed to satisfy constraint: ... and Value at 'Segment' .... ExtendDB uses another wording, and its text for a Segment at or above TotalSegments ends with the two values.
  4. An Update that stores a value nested deeper than an item may hold: the service reports the other items with their condition results (ValidationError next to ConditionalCheckFailed). ExtendDB reports None for them.

This PR adds the difference in item 13.

  1. A legacy AttributeUpdates ADD of a list, with or without members: the request-time check of this PR refuses it with 1 validation error detected: One or more parameter values were invalid: ADD action is not supported for the type L. On a table that does not exist, the service answers ResourceNotFoundException (measured 2026-11-23, two sends each), and so does main. On a table that exists, the answer of the service is not measured. A second pull request, opened after this one merges, will fix this difference. With that change, the list will pass to the table lookup, as on the service.

Merge of main at 381c8c78a

The #1000 change on main bounds the nesting depth of update expressions and of size calls in conditions and filters. This branch parses every name followed by a parenthesis as a function call. So the merge counts one level for each call that is an operand, whatever its name. A call that is the whole condition counts none. Past the limit, cd502509b checks the name of the call with the rule of the semantic pass. A name that the rule refuses gets that refusal. The service gives that refusal to 151, 200 and 300 nested calls (measured 2026-11-19, two sends each). A size call in a condition, and if_not_exists or list_append in a SET value, still answer expression nesting depth exceeded. For a name that main did not parse as a function, main answered a syntax error past the limit. #1155 lists three nests past the limit that still differ from the service.

Rebase on main

The branch was rebased onto main at f49c5f8 on 31 October. The commit ids in this description are the ones on this head. The rebase resolved this branch against these PRs of main, and each resolution holds at this head:

After the rebase the branch merged main twelve times: 6f12515, 5646709, ba4ae3d, 1700595, 63c2ba9, 2d137cc, 7efa519, a942b74, cdafc6f, 5a2facf, 1fbf065 and beafa78, the last at main 44a7b79.

Other open PRs

These are the conflicts of a dry merge (git merge-tree) of beafa78 with the head of each of the 219 open PRs, on 4 December 2026. A merge of main with the same head has none of them:

Before the merge, the head of this PR conflicted with main in crates/core/src/expression/mod.rs and crates/engine/src/expression_helpers.rs, and so with 68 other open PRs in those files. Those conflicts are gone.

#1543 (eliseong) adds validate_update_paths to crates/core/src/expression/resolver.rs. It refuses overlapping and conflicting update paths in one check. This PR adds validate_update_paths_disjoint to the same file for the overlap. The second of the two to merge keeps one check.

#597 sits on this branch, and #1140 sits on #597.

Testing done

These runs are at edb464c, the head before beafa78 (the gates on beafa78 are in Changes since the last review):

  • cargo +1.97.0 fmt --all -- --check is clean.
  • cargo +1.97.0 clippy --locked --all-targets --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooks -- -D warnings and cargo +1.97.0 clippy --locked --all-targets --features extenddb-engine/backup-test-hooks -- -D warnings are clean on the whole workspace.
  • cargo +1.94.0 check --locked --all-targets is clean on extenddb-core, extenddb-engine and the four storage crates. 1.94.0 is the rust-version of the workspace.
  • cargo +1.97.0 test --locked --no-fail-fast --lib runs on core, engine, the four storage crates and extenddb-server. Core gives 1273 passed and 1 ignored, and engine 991 passed. Cassandra gives 192 passed, MongoDB 197 passed and 86 ignored, and PostgreSQL 94 passed. SQLite gives 335 passed, 1 ignored and 2 failed, and the server gives 521 passed and 5 failed.
  • The 2 SQLite failures are the backup_catalog::write_lock_tests of storage-sqlite: the two write_lock_tests fail when an ancestor of the Cargo target directory is owned by another user #1414. The 5 server failures are backup_store::tests with the same cause. On the test host, an ancestor directory of the test paths belongs to another user, and the owner check refuses the path.
  • cargo +1.97.0 test --locked -p extenddb-wasm-adapter passes: 3 unit tests and the parity corpus test.
  • The clippy step of .github/workflows/wasm.yml (devtools/run-wasm-step clippy) is clean on the branch. The test host has no clang, so two stand-ins take the C compile of the bundled SQLite. Clippy does not link.
  • cargo +1.97.0 test --locked -p extenddb-storage-postgres --test doc_version_literals gives 3 passed.
  • A --collect-only run collects 7669 tests in tests/ and 820 in tests/python, with no error.
  • Debug builds of a SQLite server (--no-default-features --features sqlite) and a PostgreSQL server from edb464c each pass 779 cases. These are the eleven wire files that this PR adds or changes (446 cases), tests/test_error_message_key.py (4) and the three Query wire files of fix(query): check Query values against the key schema and the number rules #544 (329). Each server also passes the 105 cases of the three Query key size files that fix(query): refuse key condition values over the key size limits #481 adds to tests/python.

These runs are at 5ee0b6d, the head before the merge of main at 80490c6:

  • cargo +1.97.0 fmt --all -- --check is clean.
  • cargo +1.97.0 clippy --locked -p extenddb-engine --no-default-features --lib -- -D warnings and cargo +1.97.0 clippy --locked -p extenddb-engine --all-targets -- -D warnings are clean.
  • CLIPPY_CONF_DIR=devtools/wasm-clippy cargo +1.97.0 clippy --locked -p extenddb-engine --no-default-features --lib --release --target wasm32-unknown-unknown -- -D warnings is clean.
  • cargo +1.97.0 clippy --locked -p extenddb-wasm-adapter --all-targets -- -D warnings is clean.
  • The build and clippy steps of .github/workflows/wasm.yml compile SQLite with clang, which the test host does not have. The WebAssembly CI job runs them.

With the partiql feature on, 5ee0b6d compiles the same code as cdafc6f. So these runs at cdafc6f also hold for 5ee0b6d:

  • cargo +1.97.0 clippy --locked --all-targets --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooks -- -D warnings and cargo +1.97.0 clippy --locked --all-targets --features extenddb-engine/backup-test-hooks -- -D warnings are clean on the whole workspace.
  • cargo +1.97.0 test --locked -p extenddb-core -p extenddb-engine --lib: 1174 passed and 1 ignored in core, and 900 passed in engine.
  • On a SQLite server built from cdafc6f, the eleven wire files that this PR adds or changes and tests/test_error_message_key.py of main give 450 passed.
  • A --collect-only run collects 7002 tests in tests/ and 672 in tests/python, with no error.
  • At cdafc6f the WebAssembly CI job failed on the two functions that 5ee0b6d marks, and 59 other checks passed before the next push.
  • CI at a942b74, the head before cdafc6f, passed all 64 checks, and code scanning reported no open alert.

These runs are at 2d137cc, the approved head. The head of this description is 2d137cc plus the ten commits that Changes since the last review lists.

  • CI passed all 64 checks, run-tests (1.91.1) among them. At 2d137cc, 1.91.1 was the rust-version of the workspace.
  • cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --lib -- -W clippy::pedantic gives 35 warnings on lines that this PR adds, 31 of them doc_markdown. So the Clippy box below stays unticked.

The eleven wire files pass on a SQLite server built from 2d137cc, 443 cases in all:

File Cases Fail on main
tests/test_expression_semantics.py (new) 159 144
tests/test_transact_validation_order.py (new) 31 20
tests/test_update_expression_rules.py (new) 37 33
tests/test_transact_write_phase_order.py (new) 16 15
tests/test_request_stage_checks.py (new) 30 28
tests/test_transact_value_nesting.py (new) 6 5
tests/test_transact_capacity_order.py (new) 6 5
tests/test_expr_operand_type_and_size.py (79 new cases) 131 67
tests/test_expression_error_prefix.py 7 3
tests/test_expression_param_usage.py 12 6
tests/test_expression_size_limit.py 8 2

The last column comes from a SQLite server built from main (1d3be63), with the test files of 2d137cc. So 164 of the 190 cases in the first two files fail on main. At a942b74, tests/test_expression_param_usage.py has 15 cases, because #765 made test_scan_values_no_expression a table of four cases.

Measurements: the expected responses of the tests come from Amazon DynamoDB in us-east-1, on 2026-10-14, 2026-10-23, 2026-10-27, 2026-11-16, 2026-11-19 and 2026-11-24. The depth tests in crates/core/src/expression/depth_tests.rs use the measurement of 2026-11-19. The Scan row that a942b74 changes uses the measurement of 2026-11-24, on a table that does not exist, two sends each. Where the text of ExtendDB differs from the text of the service, the test checks part of the message. These are the known differences and the syntax wording rows.

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. The change makes wire-visible error texts and response members match the live service. CONTRIBUTING lists such changes under the RFC trigger, but this PR is a parity fix measured against the service and proposes no new protocol.

Breaking changes

ExtendDB now refuses requests that the service refuses and that ExtendDB accepted:

  • function names in the wrong case in an UpdateExpression or a condition
  • a DELETE of a value that is not a set on an absent attribute
  • a repeated update section
  • overlapping update paths
  • a nested list_append
  • an if_not_exists whose first operand is not a path
  • an undefined :value or #name in a Query or Scan filter, which returned 200 when ExtendDB evaluated no row

Before this change, only the evaluation refused the requests below. ExtendDB now refuses them before it reads the table, with the text of the service:

  • + or - on a placeholder that is not a number
  • an UpdateExpression ADD of a wrong type
  • list_append of a value that is not a list

Before the table lookup, a legacy AttributeUpdates ADD now gets the legacy text for a value other than a number or a set. This includes an ADD of a list, which the service passes to the table lookup (Known differences, item 13). A legacy DELETE with a value that is not a set also gets the legacy text. A Scan with Segment and no TotalSegments now reports an expression error ahead of the missing parameter, as the service does.

The error messages for these groups change to the text of the service. Key mismatch messages on the key-shaped APIs change to The provided key element does not match the schema. ItemCollectionMetrics is present as {} on TransactWriteItems and BatchWriteItem under SIZE with no LSI. The ConsumedCapacity array of both transaction APIs is in table creation order. ExtendDB refuses at request time the ScanFilter, QueryFilter and KeyConditions conditions that the service refuses, with the messages of the service. PartiQL statements get the same refusals (PartiQL section above).


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.

Comment thread crates/core/src/expression/parser.rs Outdated
// itself; whether that function may stand alone, whether its name exists,
// and how many operands it takes are semantic questions answered after
// the grammar pass (see `validate_condition_semantics`), so a syntax error
// further along still wins, as on Amazon DynamoDB.

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.

What does "wins" mean in this context?

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.

"Wins" meant precedence between two errors in one expression, and the comment did not say so. The grammar pass in parser.rs reports every syntax error first; the semantic checks (function name, whether a function may stand alone, operand count) run afterwards in validate_condition_semantics (crates/core/src/expression/semantics/condition_rules.rs:31), over the whole parsed tree. So for foo(pk) AND the response is the syntax error at the end of the text, not the unknown function name that appears first.

The service has the same precedence. Measured 2026-10-23 on PutItem: foo(pk) AND, ATTRIBUTE_EXISTS(pk) AND, begins_with(pk, :n) AND (with :n a number) and attribute_exists(#x) AND (with #x undefined) each answer Invalid ConditionExpression: Syntax error; token: "<EOF>", near: "AND"; foo(pk) alone answers Invalid function name; function: foo. The four cases are pinned in TestConditionFunctions.test_a_syntax_error_beats_the_semantic_errors in tests/test_expression_semantics.py (343c2fb).

I rewrote the comment to say this without the word (crates/core/src/expression/parser.rs:136-144, and the same wording in update_parser/mod.rs:279-286), in a8d83c6.

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.

The 31 October rebase rewrote the commits this reply cites: a8d83c6 is now aef6e1b, and 343c2fb is now 475465a. At 2d137cc the comment is at parser.rs:143-151 and update_parser.rs:334-343, and validate_condition_semantics is at semantics/condition_rules.rs:30, all under crates/core/src/expression/.

Comment thread crates/core/src/expression/parser.rs Outdated

let mut args = Vec::new();
if *pos < tokens.len() && tokens[*pos] != Token::RParen {
// `f()` is a syntax error on the service, reported at the `)`.

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.

A syntax error because there are no arguments? Please clarify.

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.

Yes. The service's grammar needs at least one operand between the parentheses, so attribute_exists() and foo() are refused at the ) as a syntax error, Syntax error; token: ")", near: "()", before the function name or the operand count is looked at. Measured 2026-10-23 for both spellings on PutItem (ConditionExpression); the UpdateItem case SET x = foo() was measured 2026-10-14. One operand too few is a different error: begins_with(pk) parses and the semantic pass reports Incorrect number of operands for operator or function; operator or function: begins_with, number of operands: 1 (also measured 2026-10-23).

The check is at crates/core/src/expression/parser.rs:241-251 (and update_parser/mod.rs for SET operands); the wire cases are foo(), attribute_exists() and begins_with(pk) in TestConditionFunctions in tests/test_expression_semantics.py. I rewrote the comment to say this in a8d83c6.

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.

The 31 October rebase rewrote a8d83c6, the commit this reply cites, as aef6e1b. At 2d137cc the check is at crates/core/src/expression/parser.rs:279-290, and the SET operand check at crates/core/src/expression/update_parser.rs:408-416.

Comment thread crates/engine/src/capacity_helpers.rs Outdated
/// Per-table capacity totals in the order the tables first appear in the
/// request.
///
/// Amazon DynamoDB's own order of the `ConsumedCapacity` entries of a

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 can't tell if this is saying ExtendDB's behavior (in terms of sorting) is now equivalent to DynamoDB's, or if ExtendDB is providing firmer ordering guarantees than DynamoDB (and why).

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.

It is now the service's order. DynamoDB documents no order for the ConsumedCapacity entries of a transaction, so I measured it on 2026-10-23 with three tables created on 2026-10-22, 2026-10-23 11:01 and 2026-10-23 14:45 UTC, with names that sort opposite to the creation order. For the request orders [newest, middle, oldest], [middle, newest, oldest] and [oldest, newest, middle], TransactGetItems and TransactWriteItems both returned the tables oldest first. The order follows neither the request nor the names, it follows the tables' creation time.

PerTableCapacity (now crates/engine/src/per_table_capacity.rs) orders the entries by creation time, oldest first, with name order breaking a tie. TableKeyInfo carries the creation time from the catalog row the handlers already read for the key schema, so there is no extra catalog read. Before this PR the handlers aggregated into a HashMap and the order changed between processes and backends.

Two tables tie when their stored creation times are equal, and the precision of that value differs per backend: nanoseconds on SQLite, microseconds on PostgreSQL, milliseconds on MongoDB and Cassandra. MongoDB was writing whole seconds, so three tables created inside one second got the same value and came back in name order; that write now keeps the millisecond part. A catalog row written by an earlier build still holds whole seconds. tests/test_transact_capacity_order.py creates three tables whose names sort opposite to their creation order and asserts the order on both operations; it runs against the service and against ExtendDB, and it passes on SQLite, PostgreSQL and MongoDB. docs/differences-from-dynamodb.md has the row under Capacity and Throttling, with the precision per backend.

};

// Validate begins_with operand types upfront (before any rows are read).
if let Some(ref f) = filter {

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.

Where are these checks happening now?

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.

The expression form moved them into the semantic pass. The legacy QueryFilter path lost them, which was a regression in this PR; it is fixed in 343c2fb and 4132394.

FilterExpression: the begins_with and ordering operand checks run inside the semantic pass, at request time, before the table lookup. The call is parse_condition_checked at crates/engine/src/query.rs:170, which runs validate_condition_semantics (crates/core/src/expression/semantics/condition_rules.rs:31); the begins_with operand type is at condition_rules.rs:131 and the ordering operand types at condition_rules.rs:54 and 60. The checks are in the walk because the service reports them in expression order with the other semantic errors (#x = :v AND begins_with(pk, :n) with an undefined #x reports the name, begins_with(pk, :n) AND #x = :v reports the operand type; both in TestConditionFunctions). Covered by tests/test_expr_operand_type_and_size.py and tests/python/test_begins_with_type_check.py.

QueryFilter (legacy): desugar_filter bypasses the parser, so the removal left that path with no request-time check; an empty table returned 200 and a non-empty one failed on the first row evaluated. The service checks each legacy condition at request time, before the table lookup, with its own messages. I measured the full operator by type grid on 2026-10-23: One or more parameter values were invalid: ComparisonOperator BEGINS_WITH is not valid for N AttributeValue type and the same text for every other refused pair (EQ and NE take every type; BEGINS_WITH takes S and B; CONTAINS and NOT_CONTAINS take S, N, B, BOOL and NULL; the ordering operators, BETWEEN and IN take S, N and B), plus the value count (Invalid number of argument(s) for the <op> ComparisonOperator), mixed types (AttributeValues inside AttributeValueList must be of same type), an inverted BETWEEN range and an unknown operator name. validate_legacy_condition in crates/engine/src/legacy_filter.rs now runs those checks on each QueryFilter, ScanFilter and KeyConditions entry before it is desugared, with the service's text; the Invalid FilterExpression: wording is gone. The grid is pinned in the engine's unit tests (legacy_filter_tests.rs) and one row per message on the wire in TestLegacyFilterOperandType in tests/test_expr_operand_type_and_size.py.

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.

The 31 October rebase rewrote the two commits this reply cites: 343c2fb is now 475465a, and 4132394 is now 90fdc32. At 2d137cc the lines it names are, in its order, crates/engine/src/query.rs:174, crates/core/src/expression/semantics/condition_rules.rs:30, :119, :53 and :59, and validate_legacy_condition at crates/engine/src/legacy_filter.rs:388.

Comment thread crates/engine/src/scan.rs
}

// Validate begins_with operand types upfront (before any rows are scanned).
if let Some(ref f) = filter {

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.

Similar question to query.rs: where are these checks happening now?

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.

The answer is the same as for Query. FilterExpression: inside the semantic pass through parse_condition_checked at crates/engine/src/scan.rs:197, before the projection, the unused check and the table lookup (scan.rs:300); the begins_with and ordering operand checks are at crates/core/src/expression/semantics/condition_rules.rs:131, 54 and 60.

ScanFilter (legacy): the check had been dropped. 343c2fb and 4132394 restore it in desugar_filter (validate_legacy_condition in crates/engine/src/legacy_filter.rs) with the service's messages, measured 2026-10-23 on an empty table for every operator and type: BEGINS_WITH with a number answers One or more parameter values were invalid: ComparisonOperator BEGINS_WITH is not valid for N AttributeValue type, LT with a boolean names BOOL, BETWEEN with a list then a number names L, and the value count, mixed types, inverted BETWEEN range and unknown operator get their own texts. The ScanFilter rows are in TestLegacyFilterOperandType in tests/test_expr_operand_type_and_size.py.

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.

The 31 October rebase rewrote the two commits this reply cites: 343c2fb is now 475465a, and 4132394 is now 90fdc32. At 2d137cc the lines it names are, in its order, crates/engine/src/scan.rs:179 and :309, crates/core/src/expression/semantics/condition_rules.rs:119, :53 and :59, and validate_legacy_condition at crates/engine/src/legacy_filter.rs:388.

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

Some of the agent-generated comments are read pleasantly but actually are ambiguous which makes it hard to determine whether the code is even solving a real problem. I flagged a couple. Also some operand validation code in query.rs and scan.rs was deleted and it's not obvious that it is still being done somewhere (assuming it was needed).

Comment thread crates/core/src/expression/resolver.rs Outdated
///
/// Returns `DynamoDbError::ValidationException` naming the first undefined
/// reference, names before values, in the order the expressions are given.
pub fn validate_refs_defined(

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.

Unused.

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.

Removed in d28de7a, with its re-export. It had no caller, and its doc comment described an order it did not follow, because it sorted both lists. The parser now checks the undefined references of a key condition as it walks the tokens, so the error names the first one in the text.

jcshepherd
jcshepherd previously approved these changes Oct 26, 2026

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

Dead code in resolver.rs: otherwise okay.

…ts messages

Issue #108 lists 106 requests whose response differs from Amazon DynamoDB.
Every expectation in this change was measured against the service
(us-east-1, 2026-10-14); the probes and captured responses are in the
issue's notes, and every new test file was run against the service before
it was run here.

Semantic validation of expressions. After the grammar pass, the service
walks the parsed expression once, in expression order, checking each node
after its operands, then checks overlapping paths, then unused names and
values. A new `validate_update_semantics` and `validate_condition_semantics`
in the core crate follow that walk; the parsers now do grammar only, keep
function names as written, and record section order for the walk.

- UpdateExpression: `+` and `-` take numbers, `list_append` takes lists,
  `ADD` takes a number or a set, `DELETE` takes a set; a placeholder of the
  wrong type is refused with the service's type vocabulary (`S`, `N`, `L` for
  operators and functions; `STRING`, `NUMBER`, `Binary`, `BOOL`, `NULL`,
  `LIST`, `MAP` for ADD and DELETE). Function names are case-sensitive:
  `IF_NOT_EXISTS(x, :v)` and `foo(x)` are `Invalid function name`, a
  condition function is `not allowed in an update expression`,
  `list_append` is refused as an operand of a function or of `+`, both
  functions take two operands, the first operand of `if_not_exists` is a
  document path. A repeated section is reported after that section's own
  actions (`SET a = :v SET b = :q` reports `:q`). Previously `IF_NOT_EXISTS`,
  `DELETE s :string`, and `SET a = :string + :n` were accepted and written.
- ConditionExpression and FilterExpression: the six condition functions are
  matched as written (`ATTRIBUTE_EXISTS(pk)` was accepted and evaluated);
  `if_not_exists` and `list_append` are `not allowed in a condition
  expression`; a boolean function in operand position and `size` in
  condition position are `not allowed to be used this way`; operand counts
  are fixed per function; `attribute_exists` and `attribute_not_exists` take
  a document path; `begins_with` takes a string or binary and
  `attribute_type` a string naming a type, both checked at request time with
  the operation's prefix.
- Every unused name or value is listed in one set, sorted, so the message is
  the same on every backend; it named one key chosen by hash order.

Request stage on the read APIs. Query and Scan check the FilterExpression,
then the KeyConditionExpression (with its `Invalid KeyConditionExpression:`
prefix, and ahead of the key schema match, so an undefined `#n` is reported
as such), then the ProjectionExpression, then unused names and values, all
before the table is looked up. An undefined `:q` in a filter returned 200 on
an empty table. Limit and Segment checks precede the expressions on Scan.

Single-item order. UpdateItem checks the whole ConditionExpression before
the UpdateExpression. PutItem, UpdateItem, and DeleteItem wrap every
expression-stage error in `1 validation error detected: ` and omit the
`: ConditionExpression is null` suffix; the read, batch, and transaction
APIs return the messages bare. The ` expression size: N` suffix follows the
operation. Three existing dual-target tests asserted the unprefixed text and
fail against the service; they are corrected.

Transactions. TransactGetItems and TransactWriteItems validate in phases,
each over every item before the next: per item, expressions (UpdateExpression
before ConditionExpression), unused names and values, then the item's 400 KB
size; then table lookup; then the 4 MB total; then key schema, as a
cancellation with ValidationError on the first offending item only and None
on every other (it flagged every offender); then duplicates. An undefined
reference is the request error the service returns rather than a per-item
cancellation reason, and a key schema mismatch leaves other items'
conditions unevaluated. TransactWriteItems returns `"ItemCollectionMetrics":
{}` when SIZE is requested and no table has a local secondary index, and its
ConsumedCapacity entries are in first-appearance order rather than
per-process hash order.

Key-shaped messages. GetItem, DeleteItem, UpdateItem, BatchGetItem, and
BatchWriteItem (Put and Delete) refuse a key with a missing, mistyped, or
extra attribute with `The provided key element does not match the schema`;
PutItem keeps `Missing the key pk in the item` and `Type mismatch for key`.
BatchWriteItem returns `"ItemCollectionMetrics": {}` under SIZE with no LSI.

Table ARNs in `TableName` (eight #108 rows) stay unsupported by decision: an
ExtendDB table ARN names ExtendDB's account and region, so a table that
streams or replicates to Amazon DynamoDB would answer to two ARNs.
docs/differences-from-dynamodb.md records this.

Remaining #108 gaps after this change, all stated in the PR: the parser's
syntax wording (`Syntax error; token: X, near: Y`), the ResourceNotFound
message text, the 4 MB message (the service's carries its own payload size),
the service's rendering of over-limit list values, and the table ARN rows.

Testing: tests/test_transact_validation_order.py (31 cases),
tests/test_update_expression_rules.py (37), and
tests/test_expression_semantics.py (155) pass against the service and on
SQLite, PostgreSQL, and MongoDB; 164 of the 186 cases in the first and third
fail on main. The expression, validation, transaction, batch, query, and
scan suites pass on all three backends (767 on SQLite and PostgreSQL, 751 on
MongoDB with the four #387 cases unchanged). Of the 106 #108 rows, 83 now
return the service's status, error type, and message (30 on main). cargo
test --workspace 1,500 passed; fmt; clippy -D warnings on 1.97.0; cargo
+1.88.0 check.

Closes part of #108.
@LeeroyHannigan
LeeroyHannigan removed this pull request from the merge queue due to a manual request Nov 24, 2026
@LeeroyHannigan
LeeroyHannigan added this pull request to the merge queue Nov 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 24, 2026
Main is at 89fc971, four commits after the last merge (#690, #765, #774
and #1280). One file conflicted: the docstring of
tests/test_expression_param_usage.py. #765 states that the values message
of a Scan or a Query whose AttributeValues parse has no suffix. This
branch adds the wrapped messages of the single-item writes. The merge
keeps both statements.

#765 also passes no expression parameters to the values check in
handle_scan, which merged clean. So the row of
tests/test_expression_semantics.py that sends a Scan with a
ProjectionExpression and ExpressionAttributeValues now expects the message
with no suffix. The service answered that request with the same message,
on a table that does not exist, on 24 November 2026, each request sent
twice.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

Thanks for the approval, @jcshepherd. After it, ten PRs merged into main, and two of them, #526 and #765, conflicted with this branch. Since then the branch has two new commits, 7efa519 and a942b74. Both are merges of main.

a942b74 also changes one test row. #765 dropped the : FilterExpression is null suffix from the Scan values message. So the Scan row in tests/test_expression_semantics.py now expects the message without it. The service gave the same message for that request on 2026-11-24.

The description lists the conflicts and the test runs. CI passed all 64 checks. Could you approve it again?

Main is at 3534c9e, one commit after the last merge (#1009, the
WebAssembly build). One file conflicted: crates/engine/src/lib.rs. In
the module list, this branch adds attribute_updates and
per_table_capacity, and #1009 puts a wasm32 cfg on backup and
private_fs and adds pre_dispatch. The merge keeps all of them in name
order, with each cfg and comment of #1009 above its module.

Main changed two other files that this branch changes, and git merged
them with no overlap. crates/core/src/limits/mod.rs gains page_size.
The Limit conversion in crates/storage-sqlite/src/data/query_scan.rs
saturates where usize is 32 bits.
The WebAssembly job builds extenddb-engine without its partiql
feature. The workspace depends on the engine with
default-features = false, and the wasm adapter does not enable
partiql. On this branch, strip_single_item_write_prefix and
parse_update_expr have callers only in the PartiQL module. So that
build reports both as never used, and the clippy step of the job fails
with -D warnings.

Both now carry #[cfg_attr(not(feature = "partiql"), allow(dead_code))],
as int32_member::read does on main. A build with the feature does not
change.
Main is at 80490c6, eight commits after the last merge (#596, #1173,
#398, #428, #544, #567, #584 and #588). One file conflicted:
crates/engine/src/query.rs.

#544 moves the Limit check and the parameter mix check of Query into
validate_query_request_body, which reads the raw body before
deserialization. This branch moves the same two checks to the start of
the handler, after deserialization. The merge keeps the checks of #544
and drops the copies of this branch, which no request can reach. It
keeps has_cond_op for the ConditionalOperator check.

The conflict hunks in handle_query:

- At the old Limit check, both sides remove the check. The merge keeps
  the comment of #544.
- Next, this branch keeps the variables of the mix check, and main
  keeps the index key schema. The merge keeps the key schema where this
  branch has it. It drops the mix check variables, which nothing reads
  now, and keeps the comment of #544 and has_cond_op.
- Before the ExclusiveStartKey check, this branch removes the filter
  operand checks, because its semantic pass runs them at parse time.
  #544 adds validate_key_condition_types there. The merge keeps the
  type check and drops the filter checks.

#544 refuses a begins_with value that is not an S or a B ahead of an
unused value (rows q5 and p4 of tests/test_query_key_value_types.py,
measured 2026-11-06). This branch checks unused values before the
table lookup, so the merged code gave the unused value message for
those two rows. The merge calls refuse_begins_with_on_number after the
key condition parse and removes the later call. The values of legacy
KeyConditions pass validate_legacy_conditions before that point.

Git merged four other files that both sides change, with no overlap:
crates/core/src/expression/key_condition.rs, crates/engine/src/lib.rs,
crates/storage-cassandra/tests/common/mod.rs and
docs/differences-from-dynamodb.md.
…te tests

#544 adds a TableKeyInfo literal to the test context of
crates/engine/src/query_gate_tests.rs. This branch adds the
creation_date_time field to TableKeyInfo, so the engine tests do not
compile after the merge of main at 80490c6. The literal now sets
creation_date_time to 0.0, as the other test literals on this branch do.
LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
…te tests

#544 adds a TableKeyInfo literal to the test context of
crates/engine/src/query_gate_tests.rs. The commits of #399 on this
branch add the creation_date_time field to TableKeyInfo. So the engine
tests do not compile after the merge of main at 80490c6. The literal
now sets creation_date_time to 0.0, as the other test literals on this
branch do.
@eliseong eliseong self-assigned this Nov 25, 2026
@eliseong

eliseong commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

The order DynamoDB checks an UpdateItem and a TransactWriteItems Update in, measured in us-east-1 on 25 November and 1 December 2026, each request sent twice with the same answer both times. The 1 December requests went to a table that the principal may not write, so those refusals come ahead of the IAM decision and of the table lookup.

  1. The nesting of every ExpressionAttributeValues value, including values only the ConditionExpression uses. A conflict beside a value 33 levels deep answers the nesting text (65230S5HG2DF40QT26M36JEOFFVV4KQNSO5AEMVJF66Q9ASUAAJG, NS0I6NIEK8P0G352FBQ0TSJQHBVV4KQNSO5AEMVJF66Q9ASUAAJG, N7G1R480K44LIKAOI04ARFUKGNVV4KQNSO5AEMVJF66Q9ASUAAJG).
  2. The numbers of those values. A conflict beside an unreadable number answers Number overflow on UpdateItem (149AH0BC2VINPAC1N7N7EHCSBJVV4KQNSO5AEMVJF66Q9ASUAAJG).
  3. The ConditionExpression: its undefined names and values and its operand types, together, in expression order. A conflict beside attribute_exists(#q) with #q undefined answers Invalid ConditionExpression: An expression attribute name used in the document path is not defined; attribute name: #q (UBSENAR9I32HL0CLAC1PBL1NORVV4KQNSO5AEMVJF66Q9ASUAAJG). The first undefined reference in expression order wins, names and values mixed: #b = :b AND #a = :b answers #b (R7SVVOGTD60L4JC1JB4IBM0B5VVV4KQNSO5AEMVJF66Q9ASUAAJG), :q = #a answers :q (FE46APQU1UGQS1RVPCJE6S5RHBVV4KQNSO5AEMVJF66Q9ASUAAJG). A condition reference also comes ahead of an undefined name on an update path (6394IFO6CROE58HG0H0045RADBVV4KQNSO5AEMVJF66Q9ASUAAJG).
  4. The UpdateExpression actions in order, each left path and then its right side. SET #u = :b, y = :q answers #u (OTI3SC4JNF7GOM1H9HE2KE1HGNVV4KQNSO5AEMVJF66Q9ASUAAJG), SET #u = #a answers #u (AJVBU2MJMV776ERNMD5L6N0CH7VV4KQNSO5AEMVJF66Q9ASUAAJG), and SET x = :q + #a answers :q (CVAT4Q1E2HJ95F1LTJQ0E7CJVNVV4KQNSO5AEMVJF66Q9ASUAAJG). An undefined :value comes ahead of a conflict (G61QPCOQ0KP33AU5NFOA7R134JVV4KQNSO5AEMVJF66Q9ASUAAJG).
  5. The overlap and conflict of the update paths, as one check. fix(core): refuse overlapping and conflicting UpdateExpression paths #1543 adds it as validate_update_paths.
  6. Unused names and values. A conflict beside an unused value answers the conflict (C4TQO1U4FV6PAOG4V0H1CT2V1VVV4KQNSO5AEMVJF66Q9ASUAAJG).
  7. The table and the key. On a TransactWriteItems Update a conflict answers the conflict for a missing table (0PGI0JRVHMQG2Q369BKVOMPQI7VV4KQNSO5AEMVJF66Q9ASUAAJG), an empty key value (5RAMC4LT66JCVVN2RISKQ0PQGRVV4KQNSO5AEMVJF66Q9ASUAAJG) and a key with an attribute outside the key schema (FIDV1QPLPC0G0KDNQ0FC6GKP7FVV4KQNSO5AEMVJF66Q9ASUAAJG). With several items, the service checks steps 1 to 6 for every item before it reads any table, and the earliest item's fault wins (BE51ETN6V7PDFMS0B1CGGK2F67VV4KQNSO5AEMVJF66Q9ASUAAJG, 76V77EVQQERSA7TGTND712VR0NVV4KQNSO5AEMVJF66Q9ASUAAJG).

UpdateItem puts 1 validation error detected: ahead of each of these texts; TransactWriteItems does not.

Main is at c057660, 35 commits after the last merge (80490c6).
Three files conflicted.

crates/engine/src/expression_helpers.rs: #1449 moved
check_expression_size from this file to
crates/core/src/expression/kind.rs. This branch adds
check_expression_size_with, which takes the length suffix from the
caller, and check_expression_size calls it. The merge puts
check_expression_size_with in kind.rs beside check_expression_size,
which now calls it, and exports it from extenddb_core::expression. The
engine copies of both functions go, so the size check and its message
stay in one place. The import list is the list of this branch with the
two size checks added.

crates/core/src/expression/mod.rs: in the module list, #1449 adds
search_filter and search_params, and this branch adds semantics. The
merge keeps all three in name order.

docs/differences-from-dynamodb.md: this branch adds the row on a table
ARN in TableName, and #1411 adds two rows on a DELETING table at the
same place. The merge keeps the three rows.

Git merged 13 other files that both sides change, with no overlap. In
crates/engine/src/query.rs, #481 adds the key size check and moves the
Select index check after the ExclusiveStartKey checks. Both checks come
after the request-stage checks and the table lookup of this branch. In
core, the other files are crates/core/src/expression/evaluator.rs and
its tests, and crates/core/src/validation/mod.rs. In the engine, they
are crates/engine/src/lib.rs, crates/engine/src/partiql/mod.rs and the
two transaction files. In the storage crates, they are
crates/storage-cassandra/src/backup_engine.rs,
crates/storage-mongodb/src/table_engine.rs, the ddl.rs files of the
PostgreSQL and SQLite crates, and
crates/storage-sqlite/src/data/query_scan.rs.
…ests

#481 adds crates/engine/src/query_key_size_tests.rs, whose run helper
parses each key condition with parse_key_condition_expr and gives it
only the expression and the limits. On this branch that function also
takes the expression maps. It refuses a #name or :value that the
request does not define. So the engine tests did not compile after the
merge of main at c057660.

The helper now builds the maps first. Every placeholder of the tests is
in them, so each row still reaches the size check.
…n checks

The breaking changes of this branch had no entry in the upgrade manual.
The new v1.2.0 entry comes after main's v1.2.0 entries and lists them:

- the requests that 1.1.0 served and ExtendDB now refuses
- the updates that ExtendDB refuses before it reads the table
- the prefix of the single-item writes and the key-shaped message
- the legacy condition and AttributeUpdates checks
- the transaction phases, ItemCollectionMetrics and the
  ConsumedCapacity order
- the Scan segment order and PartiQL

It also names the MongoDB tables that an earlier release created. Their
creation time keeps whole seconds, so two of them created in the same
second come in name order in ConsumedCapacity.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@eliseong I sent your shapes again on 3 December, in us-east-1, to tables that don't exist. I sent 19 shapes, each twice, and both sends gave the same answer unless I say otherwise below. The answers of #399 below are at edb464c.

  1. Nesting. In a TransactWriteItems item, fix(expressions): validate in the service's order, with its messages #399 checks the nesting of every ExpressionAttributeValues value, used or not, before the item's expressions and before any table lookup (validate_value_map_nesting in parse_write_expressions). tests/test_transact_value_nesting.py and TestBeforeTheLookup in tests/test_transact_write_phase_order.py hold that order. UpdateItem keeps the check where main has it, after the expressions and the table lookup. On the service, SET a.b = :v, a[0] = :d with :d 33 maps deep answered 1 validation error detected: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit. Main and fix(expressions): validate in the service's order, with its messages #399 answer ResourceNotFoundException. With 32 maps, SET d = :d got ResourceNotFoundException from the service. UpdateItem reads AttributeUpdates value numbers and ExpressionAttributeValues nesting after the table lookup, and the AttributeUpdates number text has no 1 validation error detected: prefix #1537 tracks the position of this check, PutItem and UpdateItem: the nesting refusal at 32 and 33 levels has no 1 validation error detected: prefix, and PutItem reports a missing table first #814 the missing prefix on our text, and PutItem, DeleteItem and UpdateItem refuse a condition-only value 32 maps deep that DynamoDB accepts #1170 the 32-map value that only a condition reads.

  2. Numbers. On UpdateItem, SET a.b = :n, a[0] = :v with :n set to 1E126 answered 1 validation error detected: Number overflow. Attempting to store a number with magnitude larger than supported range. Main and fix(expressions): validate in the service's order, with its messages #399 read those numbers after the table lookup and answer ResourceNotFoundException. UpdateItem looks the table up before it checks the numbers in ExpressionAttributeValues #1380 tracks that, and the open fix(engine): check UpdateItem value numbers before the table lookup #1385 moves the check ahead of the lookup. In a transaction item, fix(expressions): validate in the service's order, with its messages #399 reads the numbers before the nesting. A transaction Update with a 33-map value and 1E126 answered Number overflow on both sends, as fix(expressions): validate in the service's order, with its messages #399 does. On UpdateItem, the same two values answered Number overflow on one send and the nesting text on the other. These two faults can come in either order.

  3. The condition. UpdateItem checks the whole ConditionExpression first. test_update_item_checks_the_condition_first in tests/test_expression_semantics.py holds that. The walk follows expression order, names and values mixed: #b = :b AND #a = :b answered #b and :q = #a answered :q, on the service and on fix(expressions): validate in the service's order, with its messages #399. condition_function_names_and_positions in crates/core/src/expression/semantics/tests.rs has the :q = #n row. A transaction Update differs. fix(expressions): validate in the service's order, with its messages #399 checks its UpdateExpression first, as the service did on 14 October, and test_transaction_checks_the_update_first expects that. On 3 December the service answered the condition's fault for all five rows of that test. Four rows put an undefined name, an ADD of a string, overlapping paths or a syntax error in the update beside attribute_exists(#b). The fifth puts SET #a = :v beside attribute_exists(. fix(core): refuse a document path of more than 32 elements #597, which sits on this branch, checks the condition first (617ab86, measured 12 November) and changes those five rows to the condition's answers. demohan's Query and TransactWriteItems report a different fault than DynamoDB when a request has faults in more than one parameter #1474 reports the same order against main.

  4. The update actions. fix(expressions): validate in the service's order, with its messages #399 walks the actions in order, the left path and then the right side. SET #u = :b, y = :q answered #u, SET x = :q + #a answered :q, and SET a.b = :q, a[0] = :v answered :q, on the service and on fix(expressions): validate in the service's order, with its messages #399. test_references_in_expression_order and test_each_node_is_checked_after_its_operands in TestUpdateWalkOrder, and update_refs_in_expression_order in the core tests, hold that order.

  5. The paths. validate_update_paths_disjoint refuses overlapping paths after the walk of every action and before the unused names and values. It has no conflict rule. SET a.b = :v, a[0] = :v beside an unused :u answers the unused value on fix(expressions): validate in the service's order, with its messages #399. The service answered 1 validation error detected: Invalid UpdateExpression: Two document paths conflict with each other; must remove or rewrite one of these paths; path one: [a, b], path two: [a, [0]]. Your validate_update_paths in fix(core): refuse overlapping and conflicting UpdateExpression paths #1543 has both rules in one check. The fix(expressions): validate in the service's order, with its messages #399 description says that the second of the two PRs to merge keeps one check. fix(expressions): validate in the service's order, with its messages #399 calls its check in one place, at the end of validate_update_semantics, so the change that your note on fix(core): refuse overlapping and conflicting UpdateExpression paths #1543 describes replaces one call.

  6. Unused names and values. fix(expressions): validate in the service's order, with its messages #399 checks them after the walk and the overlap, in UpdateItem and in each transaction item. test_overlap_beats_unused_name in tests/test_update_expression_rules.py holds that for UpdateItem. A conflict beside an unused value gets the unused value, because of step 5.

  7. The table and the key. In TransactWriteItems, fix(expressions): validate in the service's order, with its messages #399 runs steps 1 to 6 on every item before it looks up any table, and the earliest item's fault wins. An Update with an unused :u, then an Update with a 33-map value, answered Value provided in ExpressionAttributeValues unused in expressions: keys: {:u} on the service and on fix(expressions): validate in the service's order, with its messages #399. test_unused_name_beats_earlier_missing_table and test_update_grammar_beats_missing_table_either_order in tests/test_transact_validation_order.py, and test_the_checks_follow_item_order_against_an_expression_error in tests/test_transact_write_phase_order.py, hold that. The key schema and an empty key value come in the key pass, after every lookup (TestKeyPass in the same file). On a missing table, a transaction Update with a conflict got the conflict text from the service, without the prefix. fix(expressions): validate in the service's order, with its messages #399 answers ResourceNotFoundException there, because of step 5.

The prefix: on #399, UpdateItem puts 1 validation error detected: ahead of its expression texts, and TransactWriteItems doesn't. The UpdateItem rows with P in tests/test_expression_semantics.py and test_transaction_reports_it_without_the_prefix in tests/test_update_expression_rules.py hold both forms. The UpdateItem nesting text still has no prefix, on main and on #399 (#814).

Main is at 44a7b79, five commits past c057660: #1531, #1466, #1087,
#768 and #1296. In docs/manuals/07-upgrade-manual.md, #1531 adds a
v1.2.0 entry at the top of "Behavior Changes by Release", and git
merged it with no conflict. #1087 adds its v1.2.0 entry after the other
v1.2.0 entries of main, where this branch has its entry. That is the one
conflict. The merge keeps both entries without change: the entry of
#1087 first, then the entry of this branch, before the v1.1.0 entries.

Git merged crates/storage-sqlite/src/data/query_scan.rs with no
conflict. #1087 replaces the rowid rule of the parallel Scan with the
SQL function extenddb_scan_segment. It computes the segment of a start
key from the key alone. This branch sets creation_date_time in
the TableKeyInfo of the test helper key_info. The tests that #1087 adds
in crates/storage-sqlite/src/scan_segment_tests.rs build each
TableKeyInfo from a clone, so they need no change for the new field.

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

v1 Needed for the 1.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants