Skip to content

fix(scan): check AttributesToGet, ScanFilter, ExclusiveStartKey and ExpressionAttributeValues in the service's order - #854

Open
LeeroyHannigan wants to merge 37 commits into
fix/563-scan-range-constraintsfrom
fix/564-scan-request-validation
Open

LeeroyHannigan wants to merge 37 commits into
fix/563-scan-range-constraintsfrom
fix/564-scan-request-validation

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

The review of 24 November read 1bdcf89b0. This round merges the base four times and adds five commits.

  • be52b9003 merges fix/563-scan-range-constraints at 627cb41be, which carries main at 018715e0d. One file conflicted: crates/engine/src/scan.rs. Main's fix(scan): drop the FilterExpression suffix from the values message #765 passes no expression parameters to the Scan values check. This branch moved that check from handle_scan to checked_body in crates/engine/src/scan/body_checks.rs. The merge keeps this branch's scan.rs. checked_body now passes no parameters in order R and FilterExpression in order U. The service was asked on 2026-11-24 at 15:24 UTC, on a table that does not exist, two sends each. ExpressionAttributeValues with no expression got the message with no suffix. Beside Limit: 1.5 it got : FilterExpression is null.

  • eaabbce86 merges fix/563-scan-range-constraints at 73a01aeb7, which carries main at b3c54f683. One file conflicted: crates/engine/src/int32_member.rs, in newer_form. The merge keeps this branch's newer_form, which puts the clause of an empty list member first. It calls main's validation_errors_detected, because the base deleted validation_error_envelope.

  • On the tree of be52b9003, cargo fmt --check is clean, and cargo clippy --all-targets -- -D warnings is clean on extenddb-core and extenddb-engine. The core lib tests give 1147 passed and 1 ignored, and the engine lib tests give 983 passed.

  • a2fb7ddd3 merges fix/563-scan-range-constraints at bed665f5a. That head carries fix(query): check Query values against the key schema and the number rules #544's third round (0e0f07817 and 35910e977), its merge of main at 44cd43667 and the merges of the two branches below this one. Three conflicts, all in crates/engine/src/query_key_values/value_fault.rs: the doc comments of first_fault_in and set_fault, and the signature line of first_fault_in. The merge keeps this branch's walk (first_fault_in with a member order, SetFault) and its set_fault, which builds the set texts of both paths. It drops the base's deserializer-based set_fault. Carried in: SS first in TYPE_DESCRIPTORS, so a duplicate SS beside a second type descriptor comes ahead of the numbers. Two more changes merged without conflict. One is the null member and null name handling in shape_fault_first. The other is the first pass of older_form_checks over the sets of a value the service cannot read as one type.

  • fe0e3a032 merges fix/563-scan-range-constraints at 996359746, the fix round of fix(scan): report every Limit, Segment and TotalSegments range fault in the service's two forms #850. The base moved the value fault walk to crates/engine/src/query_key_values/value_fault.rs and split its Scan range wire file. This branch's Fault, SetFault, first_fault and set_fault now live in that file, with the base's number set check (has_equal_numbers, NUMBER_SET_DUPLICATES). The base's deserializer_fault and SCAN_VALUE_EXPRESSIONS go, with no caller left. Query's older_form_checks takes the base's two passes. The base's Scan set rows in unreadable_tests.rs run through validate_before_authorization, and three of their expected texts are now the service's.

  • e0f7d6571 refuses an ExpressionAttributeValues entry nested 33 levels, where 8e4aa220 refused 32. The service accepts 32 and refuses 33. The review saw it in 7 of 7 sends, and this round on 2026-11-24 at 08:11 UTC (under Why). main accepts 32 too. nested_too_deep counts the levels of the entry as JSON, because an entry of order U may not deserialize. Core's validate_attribute_values_nesting_depth reads typed values and refuses 32 levels, the limit of the single-item writes (measured 2026-08-24). The Scan check cannot reuse it. MAX_ITEM_NESTING_DEPTH and NESTING_MESSAGE move from core's partiql module to extenddb_core::validation, so a build without the partiql feature has them. In order U the depth is a fault of the entry, in the invalid-value form, found ahead of the faults inside it (ExpressionValuesBody). The order U check in the handler, ValuesDepth and handle_partiql_scan go. The PartiQL SELECT of a whole table calls handle_scan with an empty request text. The wire rows that pair a nested value with another fault send 33 levels, each measured again on 2026-11-24.

  • fc6d8d98e reads the members of an M in an ExclusiveStartKey value in the hash order of the key's own members, on every build (the review's ExclusiveStartKey member order item). first_fault_in takes the member order as a function. first_fault keeps the parsed map's order for the other two maps, and StartKeyBody::validate passes hashed_members. The key row expects the service's text on every build. Two wire rows send the q and b bodies, and the either form of TestTwoOrders goes.

  • fba4abfc1 changes the two doc comments of the inline comments. SelectBody no longer says the service checks the Select enum ahead of the filter syntax. The ScanFilter test doc says take leaves a malformed number in the body in order R and takes it out in order U.

  • 5257ed892 moves CheckedBody and checked_body to crates/engine/src/scan/body_checks.rs as written. scan.rs has 496 lines. query_key_values.rs has 473 since the merge, where the base moved the value fault walk out.

  • 00fec65ef adds eight rows to tests/test_scan_checks_before_authorization.py, one per check the review named. They are a Limit and a Select of the wrong JSON type, ExpressionAttributeNames and ExpressionAttributeValues with no expression, ConditionalOperator and the ScanFilter value count. In order U they are a list value and the key's faults. The role extenddb-test-665-e1, which may Scan no table, sent each body twice to a table that does not exist. The sends were on 2026-11-24 at 08:28, 08:33 and 09:59 UTC. The rows carry an error code column. Two rows carry extenddb's text where the service's differs (Scan: the Segment, ScanFilter value count and COUNT with AttributesToGet checks answer texts that differ from the service #838, A request member of the wrong JSON type gets serde_json's error text, where the service sends its own #1012).

What a client sees differently from 1bdcf89b0:

  • An ExpressionAttributeValues entry nested 32 levels passes the nesting check, as on the service and on main. 33 levels are refused.
  • On a build with the MongoDB crate, the ExclusiveStartKey member {"M": {"k": {"N": "bob"}, "j": {}}} answers the empty value text with the key prefix, as the service does. Every build reads the members of an M in a key value in the hash order.

A Scan refused ahead of the IAM decision records no metric. Six malformed Scans raise UserErrors and RequestCount by 6 on main and by 0 on this branch (the review). #1190 reports the gap for every request refused in the authorization step, and #1427 fixes it at the handler's authorization error arm. This PR should merge after #1427. #1422 tracks checked_body running twice on a Scan that passes the early checks, ahead of the IAM decision and in the handler. It covers #544, #562 and this PR, and the design stays.

Changes between the review of 12 November and 1bdcf89b0

The review of 12 November read 2e3e4996d. That round merged the base and added eleven commits.

  • 5eb0132a9 merges fix/563-scan-range-constraints at 63a493394, the fix round of fix(scan): report every Limit, Segment and TotalSegments range fault in the service's two forms #850. The base now has the older-path checks of fix(query): check Query values against the key schema and the number rules #544, fix(scan): check the numbers in ExpressionAttributeValues as the service does #562 and fix(scan): report every Limit, Segment and TotalSegments range fault in the service's two forms #850 for Scan and Query. The merge keeps one copy of each check and this branch's order of the Scan checks:
    • A float or out-of-range Limit, Segment or TotalSegments puts a Scan in order U too. On the base, Limit: 1.5 beside {"N": "bob"} answers the number in the invalid-value form.
    • In order U the request-time checks are the base's older-form message, the parameter mix and the name keys. That message holds the Select and ReturnConsumedCapacity clauses (thread 1) and now the AttributesToGet length clause, last. The faulty ExpressionAttributeValues entries and an empty name come after the key's faults.
    • In order R the request-time checks are the newer form, the ReturnConsumedCapacity enum, the mix and the base's names check. Then come the base's number check in placeholder order, this branch's set check and the nesting depth.
    • The checks of the key, the ScanFilter lists and the ExpressionAttributeValues entries read each value with the base's first_fault, which now also finds set faults. Inside one value it reads the members in element order (threads 2 and 8).
  • 7496c201b sends the rows of 2026-11-23 for the older form, the lists and the key.
  • af5e0237f finds a value of the wrong JSON type before the handler holds one back (threads 3, 4 and 5).
  • 9bbf50ef3 reads the member order of the three fields in one linear pass (thread 6). A Scan with 40,000 ExpressionAttributeValues entries took 6.98 to 7.82 s on 2e3e4996d and 0.72 to 0.79 s on 9bbf50ef3 (debug SQLite servers, five sends each).
  • af556dd86 doubles the fitted table when a bucket reaches nine names (thread 9).
  • cedc43f38 accepts either answer for eavR-NSe-and-nest (thread 11). The merge did the same for eavR-two-numbers, eavR-NSbobdup-and-nest and the unit test of the two numbers. It expects the service's text for selR-arity-select-bad with an xfail for Scan: the Segment, ScanFilter value count and COUNT with AttributesToGet checks answer texts that differ from the service #838 (thread 12). The module fixtures delete their tables in a finally block.
  • ae4fa32bf moves scan_request.rs, its request tests and the wire file into files by concern, with no other change.
  • 6d2c7795c names Two faults in one request map: ExtendDB can report another member than the service #1013 in the doc of first_fault. It changes no code.
  • fafd29b61 reads the members of an M in the parsed map's order again, as the base does (thread 7). The merge had sorted them on every build. A build without the MongoDB crate sorts them by name. A build with it keeps the request's order, because bson turns on serde_json's preserve_order. The MongoDB build is one, and so is a cargo build of the whole workspace, which CI's PostgreSQL and Cassandra jobs run. On a build with the MongoDB crate, {":a": {"M": {"z": {}, "b": {"N": "fred"}}}} answers the empty value text again, and {":a": {"M": {"z": {"N": "bob"}, "b": {"N": "fred"}}}} the number text for bob, as the service does. The ExclusiveStartKey member {"M": {"k": {"N": "bob"}, "j": {}}} answered the empty value text on a build without the MongoDB crate, as the service does. On a build with it, the member answered the number text for bob. Its unit test expected the answer of the build it ran in, and its wire row accepted either answer (34fe828). fc6d8d98e reads the members of an M in a key value in the hash order on every build, so both answer the empty value text now. The service's order for the members of an M in an ExpressionAttributeValues entry is the second open part of Two faults in one request map: ExtendDB can report another member than the service #1013.
  • 34fe82848 puts EMPTY_AV back in tests/test_scan_number_values.py. The merge had dropped it, and tests/test_scan_checks_before_authorization.py imports it, so CI's pytest suites stopped at collection. The commit also made the key row above accept either answer, since CI builds both kinds.
  • 316ea8e95 runs the handler's first checks ahead of the IAM decision. In order R they end with the Select enum, and in order U with the faulty ExpressionAttributeValues entries and an empty name. At 34fe82848 two rows of tests/test_scan_checks_before_authorization.py answered AccessDeniedException in CI: {"Select": "NOPE"}, and an entry with an unknown type descriptor. The service answers both with its ValidationException to a principal allowed only DescribeTable (measured 2026-11-19). The checks moved into checked_body in crates/engine/src/scan.rs (now crates/engine/src/scan/body_checks.rs, 5257ed892). The handler calls it, and so does scan_request::validate_before_authorization, which the server runs ahead of the IAM decision. The server passes the request text too, so the member order of the three maps is the one the handler reads.
  • 1bdcf89b0 changes a claim in the doc of order R step 9 and in the comment beside the Select check. They said the service makes the Select enum ahead of the filter syntax (2026-11-05). No row of this branch sends the two together. On 2026-11-19 the service answered the filter's text ahead of an invalid Select (Scan reports an invalid Select ahead of the filter checks, and the table lookup and the IAM decision ahead of the Segment pairing check #1391, under Known differences). It changes no code.

What a client sees differently from 2e3e4996d:

  • Both enums beside a value the service cannot read, or beside Limit: 1.5, answer both clauses in one message, with the range and length clauses.
  • Limit: 1.5 beside {"N": "bob"} answers the number in the invalid-value form, after the key's faults.
  • In order R, two malformed numbers name the first by placeholder. Beside a nested value, {"NS": ["bob", "1", "1"]} in another entry answers bob ahead of the nesting text. The service varies on both (the counts are under Why).
  • In order U, a ScanFilter list names its first faulty value in the list's order, a number or a set fault included. A key member names its first fault in element order, the members of an M in the hash order.
  • A member of the wrong JSON type inside a value answers SerializationException, also behind a value fault in the same map or list.
  • Nine names in one bucket of sixteen name the entry the doubled table puts first.
  • The ExpressionAttributeNames checks of the base run, and in order U an empty name comes after the faulty entries.
  • On a build with the MongoDB crate, {":a": {"M": {"z": {"N": "bob"}, "b": {"N": "fred"}}}} answers the number text for bob, as the service does. The reviewed head read the numbers of a readable M in sorted order on every build, so it answered fred there.
  • An ExpressionAttributeValues entry nested 32 levels passes the nesting check, as on the service. 2e3e4996d refused it.

What a client sees differently from the base at 63a493394 (the base is 996359746 now, and the fix round of #850 describes its own changes):

  • An NS with duplicates in ExpressionAttributeValues answers One or more parameter values were invalid: Input collection contains duplicates., as the service does. That base gave the deserializer's text with the members listed.
  • {":a": {}, ":n": {"N": "bob"}} names :n, as the service does. That base named :a.
  • In order U the key's faults come ahead of the faulty entries and an empty name, as the service answers.
  • The server's checks ahead of the IAM decision are the handler's first checks. In order R they end with the Select enum, and in order U with the faulty ExpressionAttributeValues entries and an empty name. A principal that may not Scan the table gets the ValidationException of an invalid Select and of a faulty entry, as on the base. It also gets the answer of each check the service makes ahead of those two. These are a member of the wrong JSON type, the no-expression checks, ConditionalOperator and the ScanFilter value count. In order U they also include the ScanFilter list values and the key's faults. The base made these after the IAM decision and answered AccessDeniedException to that principal. The role extenddb-test-665-e1 sent those rows to the service on 2026-11-24 and got each check's answer (00fec65ef, under Why).

What

Stacked on #850 (fix/563-scan-range-constraints), which sits on #562 and #544. The branch covers items 1, 2, 4 and 5 of #564, with one row of item 5 left open (below). Item 3 is a malformed number in a ScanFilter list in order R. It is also item 3 of #477, and #507 covers it (the comment of 25 October on #564).

The service checks a Scan request in one of two orders. A request on the service's older validation path follows order U. Such a request holds a value the service cannot read as one type, or a Limit, Segment or TotalSegments that is a float or outside int32. The value is a null or empty, or carries an unknown or lower-case type descriptor, two descriptors or a null payload. It can sit at the top or inside an L or M. The places read are the ExpressionAttributeValues entries, the ExclusiveStartKey values and the ScanFilter lists. Every other request follows order R. The same test picks the older form of the constraint clauses (#563). crates/engine/src/scan_request.rs computes it once per request (CheckOrder), and its module doc lists both orders.

Order R:

  1. the newer form: the AttributesToGet length, then the Limit, Segment and TotalSegments ranges, in one message
  2. the ReturnConsumedCapacity enum
  3. the parameter mix, in which an object ScanFilter counts as present whether or not it is empty
  4. the ExpressionAttributeNames checks (fix(scan): check the numbers in ExpressionAttributeValues as the service does #562)
  5. every number in ExpressionAttributeValues, the entries in placeholder order (fix(scan): check the numbers in ExpressionAttributeValues as the service does #562). The numbers of the ScanFilter lists are fix(query): check legacy conditions against the key schema #507's check
  6. an empty or duplicate set in ExpressionAttributeValues, in placeholder order, with the set texts of order R
  7. the nesting depth of ExpressionAttributeValues: an entry nested 33 levels or more, with M levels counted as L levels
  8. the request parameter checks: ExpressionAttributeNames with no expression, ExpressionAttributeValues with no expression, ConditionalOperator with no ScanFilter, a ScanFilter condition's value count
  9. the Select enum
  10. the expression checks: the filter syntax, the projection syntax, an undefined value, the operand types, the Select rules, the unused values, COUNT with a ProjectionExpression, COUNT with AttributesToGet, the Segment pairing
  11. the key's number and set faults, in the member order below
  12. the table lookup, the index resolution, the index rules, the key schema

Order U:

  1. the older form: an invalid Select, the TotalSegments fault, an invalid ReturnConsumedCapacity, the Segment fault, the Limit fault and an empty AttributesToGet, in one message (fix(scan): report every Limit, Segment and TotalSegments range fault in the service's two forms #850 builds it)
  2. the parameter mix, then the ExpressionAttributeNames key checks
  3. ExpressionAttributeNames and ExpressionAttributeValues with no expression, then the ScanFilter list values, then ConditionalOperator with no ScanFilter and a ScanFilter condition's value count. In a list the first faulty value in the list's order is named, with no prefix. Its fault is a value the service cannot read, a malformed number or a set fault. The conditions are visited in the member order below
  4. the key's faults: the first faulty member in the member order below. A value the service cannot read carries the prefix The provided starting key is invalid: . A number carries the number check's text. A set fault carries the texts of order U (below)
  5. the ExpressionAttributeValues entries, in the member order below, the first faulty one named, each fault in the form ExpressionAttributeValues contains invalid value: <text> for key :a. An entry nested 33 levels or more is a fault of the entry, found ahead of the faults inside it. Then an empty name in ExpressionAttributeNames
  6. the expression checks and the table

Inside one value, the first fault is the one first_fault_in (crates/engine/src/query_key_values/value_fault.rs) finds. It reads L members in their order. In an ExpressionAttributeValues entry or a ScanFilter list value it reads M members in the parsed map's order (first_fault). A build without the MongoDB crate sorts them by name, and a build with it keeps the request's order (#1013). In an ExclusiveStartKey value it reads them in the hash order below on every build (hashed_members in crates/engine/src/scan_request/holders.rs). Inside one bucket the parsed map's order stands in for the request's. With several type descriptors it reads each payload and answers the more-than-one text only when no payload has a fault. This branch adds the set faults to it, for Scan. Query does not ask for them.

The handler in crates/engine/src/scan.rs holds back the values each order reports late, so that the typed deserialization does not report them first (checked_body in crates/engine/src/scan/body_checks.rs). They are the key (StartKeyBody), and in order U the faulty ExpressionAttributeValues entries and an empty name (ExpressionValuesBody) and the faulty ScanFilter list values (ScanFilterBody). In order R it holds back an invalid Select (SelectBody). A readable stand-in replaces each value taken out. Ahead of every check, value_shape_fault reads each of those values on its own, so a member of the wrong JSON type inside one answers SerializationException first.

The service visits the members of ExclusiveStartKey in the iteration order of a Java HashMap over the names. In order U it visits the entries of ExpressionAttributeValues and the conditions of ScanFilter in that order too. It takes String.hashCode() of each name, spreads it as h ^ (h >>> 16), and masks it to the table's buckets. The names go into the table in the request's order. The table starts with four buckets and doubles when it holds more than three quarters of its size. It also doubles when a name is the ninth in its bucket and the table has fewer than 64 buckets. The buckets come in ascending order, and the request's order holds inside a bucket. Names outside ASCII hash on their UTF-16 code units, a name outside the Basic Multilingual Plane (U+1D11E) on its two. The rule is fitted to the measured rows. The service does not document it. The code comment at fitted_member_order (crates/engine/src/scan_request/member_order.rs) states the rows. The parsed body sorts object members on every build but the MongoDB one. So the handler reads the request's order of the three fields from the request text, in one pass (member_orders). dispatch passes the request text to the handler.

The set texts follow the order. Order R quotes the members as JSON strings: Input collection ["a", "a"] contains duplicates. and Input collection ["YQ==","YQ=="]of type BS contains duplicates.. The service gives the same text for these members. For members out of sorted order or with a control character it differs (under Known differences). Order U does not quote them: Input collection [a, a] contains duplicates.. For an NS in order U the text is Input collection contains duplicates, with no prefix and no full stop. An empty SS and an empty BS in the key carry the key prefix in order U. An empty NS does not. The texts come from SetFault::text in crates/engine/src/query_key_values/value_fault.rs.

One row of item 5 stays open. From 63 L levels the JSON parser refuses the body (128 JSON levels, two per L level) before any check reads it. ExtendDB answers SerializationException where the service answers the prefixed nesting text. #807 changes request parsing, which every operation shares, and covers these depths.

The PartiQL SELECT of a whole table calls handle_scan with an empty request text, so the parsed body's member order stands in for the request's. It runs every check of a Scan, the nesting check among them. The service accepts a 32-level parameter in such a SELECT and refuses 33 levels with the nesting text, as it does for a Scan entry. The PartiQL parameter check makes that refusal before the engine reads the statement.

Why

Refs #564.

Measured against DynamoDB (us-east-1) on 2026-10-25 at 10:38 and 10:55 UTC, on 2026-10-30 at 12:40 UTC and on 2026-10-31 between 23:54 and 23:56 UTC. Measured again on 2026-11-05 between 00:54 and 01:05 UTC, at 03:18 UTC, at 05:31 UTC, at 06:20 UTC and at 07:38 UTC. The probe sent each request twice, as a raw signed Scan. The key with two number faults was sent again on 2026-11-04 at 23:45 UTC. The rows of the round before went out on 2026-11-23 at 14:03, 14:12 and 21:49 UTC, to a table that does not exist. The rows of this round went out on 2026-11-24 at 08:11, 08:28, 08:33, 08:46, 08:47, 08:59 and 09:59 UTC. Each went twice, to tables that do not exist.

  • An empty ScanFilter counts as present for the parameter mix. ScanFilter: {} with a FilterExpression answers Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {ScanFilter} Expression parameters: {FilterExpression}. The service accepts ScanFilter: {} alone.
  • AttributesToGet: [] answers 1 validation error detected: Value at 'AttributesToGet' failed to satisfy constraint: Member must have length greater than or equal to 1: alone, with a FilterExpression, with a FilterExpression and a malformed number, and with ScanFilter: {} and a FilterExpression. The length constraint joins the range constraints. Limit: 0 with AttributesToGet: [] answers 2 validation errors detected: Value at 'AttributesToGet' failed to satisfy constraint: Member must have length greater than or equal to 1; Value at 'Limit' failed to satisfy constraint: Member must have value greater than or equal to 1.
  • A malformed N in ExclusiveStartKey answers The parameter cannot be converted to a numeric value: bob. That holds with a valid filter, with no filter, and in the index key of a GSI scan and of an LSI scan. It holds for an NS member, an L member, and a number in the L of an attribute that is not a key attribute. On an N hash key, " 1" and "" answer the same text with the value echoed. 39 digits answer Attempting to store more than 38 significant digits in a Number. {"pk": {"N": "bob"}} alone, with no sk, answers bob ahead of the key schema check (2026-11-05).
  • The constraint clauses come ahead of every key fault. In order R they take the newer form (Value at 'Limit' ...), in order U the older form (Value '0' at 'limit' ...).
  • No single order fits the measured rows. {"pk": {}, "sk": {"S": "x"}} with Select: "BAD" answers the Select clause. A value nested 32 levels with Select: "BAD" answers the nesting text. The same nested value beside that key answers the key's text. The three rows fit the two orders above, and so does every other measured row.
  • Order R, the enums and the request parameter checks (2026-11-05): ReturnConsumedCapacity: "BAD" beside the parameter mix and beside Select: "BAD" answers its own clause. ExpressionAttributeNames with no expression answers its text ahead of ExpressionAttributeValues with no expression and of ConditionalOperator. ConditionalOperator answers its text ahead of a ScanFilter condition with no value. {":e": {"NS": []}} with no expression answers One or more parameter values were invalid: An number set may not be empty ahead of the no-expression check. ExpressionAttributeValues with no expression and Select: "BAD" answers the no-expression text. The mix beside Select: "BAD" answers the mix text.
  • Order R, the nesting check: an ExpressionAttributeValues value nested 33 to 62 L or M levels deep answers Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit. 32 levels answer the next check's text. On 2026-11-24 at 08:11 UTC an L chain and an M chain around {"N": "1"}, read by the filter, went to a table that does not exist. They answered ResourceNotFoundException at 30, 31 and 32 levels, the nesting text at 33, 34 and 62, and the wrapped text below at 63 and 64. The rows of 2026-10-30 and 2026-10-31 answered the nesting text at 32 levels. The reviewer's 7 of 7 sends of 24 November and every send here answer the next check's text there. The nesting text comes ahead of the Select enum, the filter syntax, the no-expression check and a number in the key. That was measured at 32 levels on 2026-10-30, 2026-10-31 (B4-5a) and 2026-11-05, and at 33 levels on 2026-11-24 at 08:46 UTC. The nesting text holds for a value the filter reads and for one nothing reads, with an N or an S leaf. An empty NS in another entry answered its set text ahead of the nesting text ({":p": {"S": "x"}, ":d": <nested>, ":e": {"NS": []}}). It did so in both sends on 2026-11-05 at 06:20 UTC and in 4 of 4 on 2026-11-23, at 32 levels. At 33 levels it did so in 2 of 2 on 2026-11-24. It answered the nesting text in 12 of 14 sends on 2026-11-12. {"NS": ["bob", "1", "1"]} in another entry answered the nesting text on 2026-11-05. It answered bob in 4 of 4 sends on 2026-11-23 and the nesting text in 3 of 6 on 2026-11-12. At 33 levels it answered bob in 1 of 2 on 2026-11-24. {"L": [{"N": "bob"}, {"NS": []}]} in another entry answered the number in one send and the nesting text in the other. That held on 2026-11-05 and again on 2026-11-24. An SS with duplicates in another entry answered its duplicates text in one send and the nesting text in the other. That held on 2026-11-05 at 07:38 UTC and on 2026-11-24. The service reports a malformed number at the bottom first, at every depth measured. The depths were 31 to 60 and an M at 32, and 33 on 2026-11-24 in 2 of 2 sends. From 63 levels the text is ExpressionAttributeValues contains invalid value: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit for key :d. The depths 63, 70, 80, 99 and 100 were measured, and 63 and 64 again on 2026-11-24.
  • Order R, the expression checks among themselves (2026-11-05, each pair sent together): the filter syntax ahead of the projection syntax, SPECIFIC_ATTRIBUTES, ALL_PROJECTED_ATTRIBUTES and the Segment pairing. An undefined value ahead of the unused values, the Segment pairing and SPECIFIC_ATTRIBUTES. An operand type ahead of the unused values and the Segment pairing. The unused values ahead of COUNT with a ProjectionExpression and of the Segment pairing. COUNT with AttributesToGet ahead of the Segment pairing.
  • Order R, the key's value faults, after the expression checks and ahead of the table lookup, with no prefix. Beside {"pk": {"N": "bob"}, "sk": {"S": "x"}}, each expression check answers its own text. A missing index, ConsistentRead on a GSI and a missing table answer the number text. The set texts are One or more parameter values were invalid: An number set may not be empty, ... An string set may not be empty and ... Binary sets should not be empty. A set with duplicates answers ... Input collection contains duplicates. for an NS (["1", "1"] and ["1", "1.0"] alike), ... Input collection ["a", "a"] contains duplicates. for an SS (["a\"b", "a\"b"] for members with a quote) and ... Input collection ["YQ==","YQ=="]of type BS contains duplicates. for a BS. In an NS, ["bob", "1", "1"] and ["1", "1", "bob"] answer bob. The service reports a number in ExpressionAttributeValues ahead of a number in the key. A malformed number in a ScanFilter list answers The parameter cannot be converted to a numeric value: bob (2026-11-05 at 05:31 UTC). It does so alone and beside {"pk": {"N": "fred"}, "sk": {"S": "x"}} in the key. That check is fix(query): check legacy conditions against the key schema #507's and is not made here. Beside an empty NS in another entry, a malformed number in ExpressionAttributeValues answered the empty-set text in one send and the number text in the other. An empty NS answers its text ahead of ExpressionAttributeNames with no expression and ahead of Select: "BAD", and after ReturnConsumedCapacity: "BAD". ConditionalOperator and a ScanFilter condition with no value answer their texts ahead of Select: "BAD".
  • Order R, two faulty entries (2026-11-05 at 07:38 UTC). {":n": {"N": "fred"}, ":a": {"N": "bob"}} answered fred on 2026-11-05. On 2026-11-23 it answered fred in 4 of 6 sends and bob in 2, and on 2026-11-12 each in 7 of 14. The placeholder order names bob. {":n": {"NS": []}, ":a": {"SS": []}} answered One or more parameter values were invalid: An string set may not be empty in one send and ... An number set may not be empty in the other. An empty NS beside the parameter mix answers the mix text.
  • Order U, the key's faults (2026-11-05). A key value that is empty or carries an unknown or lower-case type descriptor answers The provided starting key is invalid: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes. A key value with two descriptors answers The provided starting key is invalid: Supplied AttributeValue has more than one datatypes set, must contain exactly one of the supported datatypes. An empty value inside an L or M, or in a member that is not a key attribute, answers the first text too. Five checks answer their own text beside such a key. They are ExpressionAttributeValues with no expression, ExpressionAttributeNames with no expression, ConditionalOperator with no ScanFilter, a ScanFilter condition with no value, and the parameter mix. Nine checks answer the key's text beside it. They are the filter syntax, an undefined value, the operand types, the projection syntax, the three Select rules and the unused value. The Segment pairing does too, with each of its three faults. The three table checks (a missing index, ConsistentRead on a GSI and a missing table) do too. A nested value the filter reads does too, with an S or an N leaf. So does a nested value nothing reads.
  • Order U, the ExpressionAttributeValues entries (2026-10-31 B4-7 and 2026-11-05). An empty entry the filter reads answers ExpressionAttributeValues contains invalid value: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes for key :a with no key, with a valid key and on a missing table. An entry nothing reads answers the same text for its key, ahead of the nesting check (B4-7) and of the unused values. {"X": "1"} answers the empty-value text in that position. Two descriptors answer the more-than-one text with the same wrapper. The entry's text comes ahead of the filter syntax, an undefined value and the projection syntax. Beside Select: "BAD" or ReturnConsumedCapacity: "BAD" the enum clause comes first, and beside the parameter mix and Select: "BAD" the Select clause does. Beside a key fault the key's text comes first. A malformed number in the map answers ExpressionAttributeValues contains invalid value: The parameter cannot be converted to a numeric value: bob for key :a. It comes after the key's faults: {":n": {"N": "bob"}} beside {"pk": {}, ...} answers the key's text, with and without an empty entry. The entries are visited in the member order below. {":p": {"S": "x"}, ":a": {"N": "bob"}, ":e": {}} names :a, and the same with :n names :n. {":p": {"S": "x"}, ":b": {}, ":a": {"X": "1"}} names :b. An empty value at the bottom of 32 L levels is named too: {":d": <32 levels around {}>} answers the empty-value text for :d (2026-11-05 at 06:20 UTC). At 33 levels the entry answers the nesting text in the same form, ahead of the fault inside it (2026-11-24 at 08:46 and 08:47 UTC). {":d": <33 levels around {}>} answers ExpressionAttributeValues contains invalid value: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit for key :d. A 33-level :p beside Limit: 1.5 answers it for :p. A 33-level :d is named ahead of {} in :e (B4-7), and {} in :b is named ahead of a 33-level :d. The key's faults come ahead of a 33-level entry (2026-11-24 at 08:46 and 08:59 UTC, six key rows). A set fault in an entry takes the same form (2026-11-05 at 07:38 UTC): {":p": {"S": "x"}, ":s": {"NS": []}, ":e": {}} answers ExpressionAttributeValues contains invalid value: One or more parameter values were invalid: An number set may not be empty for key :s, and an SS with duplicates there ... Input collection [a, a] contains duplicates. for key :s. A malformed number inside an L or an NS answers the number text for its key, and 39 digits ... Attempting to store more than 38 significant digits in a Number for key :a. {":p": {"S": "x"}, ":e": {}, ":a": {"N": "bob"}} names :e: :a and :e share a bucket and the request's order decides. With four entries and with seven the entry the eight and sixteen buckets put first is named. Inside one entry {"L": [{"N": "bob"}, {}]} answers the number.
  • Order U, the ScanFilter list values (2026-11-05 at 05:31 UTC). [{}] and [{"X": "1"}] answer Supplied AttributeValue is empty, must contain exactly one of the supported datatypes, with no prefix. ExpressionAttributeNames with no expression answers its text ahead of the list value. The list value answers its text ahead of ConditionalOperator, a condition with two values, a key shape or number fault and a missing table. Select: "BAD" answers its clause ahead of the list value. Two descriptors in a list value answer Supplied AttributeValue has more than one datatypes set, must contain exactly one of the supported datatypes, and an empty value inside an L the empty-value text (2026-11-05 at 07:38 UTC). With two conditions the one first in the member order below is named: pk ahead of sk, and ts ahead of id when ts comes first. In one list the first faulty value is named: on 2026-11-23 [{}, {"NS": []}] answered the empty value and [{"N": "bob"}, {}] the number. ExpressionAttributeValues with no expression answers its text ahead of the list value. An invalid ComparisonOperator answers its constraint clause ahead of the list value, a legacy-condition check this branch does not make (below). In order R an empty NS in a list answers One or more parameter values were invalid: An number set may not be empty, the deserializer's text here.
  • Order U, the key's set texts (2026-11-05). Beside an empty ExpressionAttributeValues entry the filter reads, a key NS with duplicates answers Input collection contains duplicates and a key SS with duplicates One or more parameter values were invalid: Input collection [a, a] contains duplicates.. An empty key NS answers One or more parameter values were invalid: An number set may not be empty there and beside an unreadable key member. An empty key SS beside an unreadable key member answers The provided starting key is invalid: One or more parameter values were invalid: An string set may not be empty. Beside an empty ExpressionAttributeValues entry the filter reads it answers the same. An empty key BS beside an unreadable key member answers The provided starting key is invalid: One or more parameter values were invalid: Binary sets should not be empty. A key BS with duplicates there answers One or more parameter values were invalid: Input collection [YQ==, YQ==]of type BS contains duplicates.. The empty key BS keeps the prefix beside an empty ExpressionAttributeValues entry the filter reads (2026-11-05 at 07:38 UTC). It keeps it inside an L and in a member that is not a key attribute.
  • The older form on 2026-11-23. {"Select": "BAD", "ReturnConsumedCapacity": "BAD"} beside an empty entry, and beside "Limit": 1.5, answers 2 validation errors detected: Value 'BAD' at 'select' ...; Value 'BAD' at 'returnConsumedCapacity' .... "AttributesToGet": [] beside "Limit": 0.0 answers 2 validation errors detected: Value '0' at 'limit' ...; Value '[]' at 'attributesToGet' failed to satisfy constraint: Member must have length greater than or equal to 1. With the five other faults the order is select, totalSegments, returnConsumedCapacity, segment, limit, attributesToGet. Beside Select: "BAD" and an empty entry the two clauses are select and attributesToGet.
  • Order U, more rows of 2026-11-23. The key member {"L": [{"N": "bob"}, {}]} answers the number. An empty key value comes ahead of an empty name. A member of the wrong JSON type answers SerializationException behind a value fault: {":a": {"L": [{"S": 5}, {}]}} and the key {"pk": {"NS": []}, "sk": {"S": 5}} answer NUMBER_VALUE cannot be converted to String. "AttributesToGet": [] beside a key with an empty NS and "Limit": "5" answers STRING_VALUE cannot be converted to Integer.
  • The member order (2026-10-31, 2026-11-04 and 2026-11-05). The rows are 112 with a shape fault among two faulty members on five tables, and five rows on two more. On the pk, sk table the service names sk in both request orders. On HASH a, RANGE b it names a. On HASH pk, RANGE a it names a in both request orders. On ts, id and on id, ts it names the member first in the request. On HASH ä, RANGE é it names ä in both request orders. On the GSI, {"gpk": {}, "pk": {"N": "bob"}, "sk": {"S": "x"}} names gpk. On a GSI with a range key the key has four members. There {"gpk": {}, "gsk": {"N": "bob"}, "pk": ..., "sk": ...} names gpk in both request orders, and {"gpk": ..., "gsk": {}, "pk": {"N": "bob"}, "sk": ...} names pk. Four buckets would reverse both. Eight buckets give them. Every row fits the hash order above. On 2026-11-23 eight, nine and ten ExpressionAttributeValues entries shared bucket 10 of sixteen, with :aa first and :dt last in the request, both empty. The eight named :aa, and the nine and the ten named :dt. With the table doubled at the ninth name in one bucket, :dt falls in bucket 10 of 32, ahead of the others in bucket 26. With two value faults and no shape fault the service's two sends disagreed on 19 of the 40 matrix cells (20 pairs, both request orders). {"pk": {"N": "bob"}, "sk": {"N": "fred"}} answered bob on 2026-10-31 and fred on 2026-11-04. The tests for those rows accept either member's fault.
  • The members of an M in an ExclusiveStartKey value (2026-11-24 at 08:11 UTC). {"pk": {"M": {"q": {"N": "bob"}, "b": {}}}, "sk": {"S": "s"}} answers The parameter cannot be converted to a numeric value: bob. {"pk": {"M": {"b": {"N": "bob"}, "q": {}}}, "sk": {"S": "s"}} answers the prefixed empty-value text. So does {"pk": {"M": {"k": {"N": "bob"}, "j": {}}}, "sk": {"S": "s"}}, as the member {"M": {"k": {"N": "bob"}, "j": {}}} did on 2026-11-05 in a member that is not a key attribute. With four buckets q is in bucket 1, b and j in bucket 2 and k in bucket 3. So the hash order above names bob, the empty value and the empty value. Request order would name bob for all three, and sorted order the empty value, bob and the empty value.
  • The checks ahead of the IAM decision, as the role extenddb-test-665-e1, which may Scan no table. The bodies went to a table that does not exist on 2026-11-24 at 08:28, 08:33 and 09:59 UTC. {"Limit": "5"} answers SerializationException with STRING_VALUE cannot be converted to Integer, and {"Select": 5} with NUMBER_VALUE cannot be converted to String. ExpressionAttributeNames with no expression answers its text. ExpressionAttributeValues with no expression answers ExpressionAttributeValues can only be specified when using expressions. Beside Limit: 1.5 it answers the same text with the suffix : FilterExpression is null (Scan: ExpressionAttributeValues without an expression answers with a ": FilterExpression is null" suffix the service does not send #722). ConditionalOperator alone answers ConditionalOperator cannot be used without Filter or Expected. A ScanFilter condition with no value answers One or more parameter values were invalid: Invalid number of argument(s) for the EQ ComparisonOperator. In order U, [{}] in a ScanFilter list answers the bare empty-value text and {"pk": {}, "sk": {"S": "x"}} the prefixed one. {"N": "bob"} and Select: "NOPE" answer as on 2026-11-19, and a valid body answers AccessDeniedException. "ConsistentRead": "yes" alone answers AccessDeniedException too: the service reads the string as a boolean (A boolean member given as a JSON string is read differently from the service #984). As the Admin role the same body answers ResourceNotFoundException (08:31 UTC).

main (25ee109bf, a SQLite server) accepts ScanFilter: {} with a FilterExpression. It scans and compares for {"N": "bob"} in a ScanFilter list (200, no item), as every commit of this branch does. The check is #507's. It answers Invalid ProjectionExpression: The expression can not be empty; for AttributesToGet: [] alone, with a FilterExpression and with Limit: 0. The #562 base answers the Limit clause alone for that last request, in the newer form. For a malformed ExclusiveStartKey number on an S key, main answers the key schema text (The provided starting key is invalid: The provided key element does not match the schema). On an N sort key it answers 500 InternalServerError, and on an N hash key it scans and returns no items. For " 1", "" and 39 digits on an N hash key it scans the table. main reports an empty key value, two descriptors and the set faults with the deserializer's texts, ahead of every handler check. It reports an unknown descriptor as a SerializationException. main has no nesting check on Scan: 32 levels answer the unused-value text or scan, and from 63 levels the JSON parser's recursion limit answers SerializationException: Start of structure or map found where not expected: recursion limit exceeded.

Known differences (main differs from the service on each of them too):

Overlaps with other PRs

Not measured, kept in the code's order

  • The AttributesToGet length clause beside a Segment or TotalSegments fault alone, and against ReturnConsumedCapacity in order R.
  • ScanFilter: {} and AttributesToGet: [] with a ProjectionExpression.
  • In order R, the nesting check against ExpressionAttributeNames with no expression, ConditionalOperator and the ScanFilter value count.
  • The projection syntax against an undefined value, an operand type and the unused values.
  • The text of a set fault in a ScanFilter list value in order U (the texts of order U).
  • In order U, the Select enum against the mix (the enum first). The mix beside Select: "BAD" and an empty entry answers the Select clause.
  • An empty value ahead of a malformed number inside one ExpressionAttributeValues entry (the empty value, the element order). The number ahead of the empty value is measured.
  • A set fault in ExpressionAttributeValues against the key's faults (the key first, the set fault with the map's entries).
  • A BS with duplicates in the key beside an unreadable expression value (no key prefix, the members unquoted).
  • Six names in a map (eight buckets, measured for four, five and seven).
  • Nine names in one bucket of a table of 64 buckets or more. Java's HashMap makes such a bucket a tree, which moves one of its names to the front. The code keeps the request's order there.
  • Two value faults inside one NS (the request's order).
  • The order of two members of an M in an ExclusiveStartKey value that share a bucket (the parsed map's order stands in for the request's).
  • Query keeps its checks. Query has no nesting check, and its AttributesToGet and QueryFilter forms were not measured.
  • 63 to 100 levels: the open row above.

Where the service's own sends disagreed, the code names one of the answers and the tests accept either. Those are a set fault in ExpressionAttributeValues against a malformed number in another entry (the number first here), and two set faults (the first by placeholder). They also cover two malformed numbers, a number or a set fault beside a nested value, and two value faults in two key members.

Testing done

At a2fb7ddd3, the merge of the base at bed665f5a:

  • cargo +1.97.0 test -p extenddb-engine --lib: 969 passed on the default build and 969 in a build with extenddb-storage-mongodb (serde_json/preserve_order on). cargo +1.97.0 test -p extenddb-core --lib: 1147 passed, 1 ignored.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage-sqlite --all-targets -- -D warnings gave 0 warnings, and so did -p extenddb-engine with --features extenddb-engine/backup-test-hooks and -p extenddb-core with --no-default-features. cargo +1.91.1 check -p extenddb-core -p extenddb-engine -p extenddb-server --all-targets gave 0 warnings.
  • Wire tests on a debug SQLite server. tests/test_partiql_item_depth.py, test_scan_checks_before_authorization.py, test_scan_number_values.py, test_query_scan.py, test_query_value_shapes.py, test_query_key_value_types.py and test_query_leading_keys_values.py gave 573 passed and 3 xfailed. tests/python/test_scan_request_rows.py, test_scan_request_validation.py, test_scan_range_constraints.py and test_scan_range_constraints_beside_values.py gave 356 passed and 3 xfailed. The 18 more than at 00fec65ef are the rows fix(query): check Query values against the key schema and the number rules #544's third round adds.
  • On a MongoDB server (--features mongodb, a mongo:7 replica set on 127.0.0.1, EXTENDDB_TEST_BACKEND=mongodb): the five tests/ files above without test_query_scan.py and test_query_leading_keys_values.py, and test_scan_request_rows.py, test_scan_request_validation.py and test_scan_range_constraints_beside_values.py gave 753 passed and 6 xfailed.
  • pytest --collect-only collects 7371 tests in tests/ and 1031 in tests/python/, with no error.

At 00fec65ef:

  • cargo +1.97.0 test --locked -p extenddb-engine --lib: 969 passed. The 88 unit tests of scan_request, query_key_values and int32_member also pass with serde_json/preserve_order on, in a build with extenddb-storage-mongodb.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy --locked -p extenddb-engine -p extenddb-server --all-targets -- -D warnings gave 0 warnings, with and without --features extenddb-engine/backup-test-hooks. cargo +1.91.1 check --locked -p extenddb-engine -p extenddb-server --all-targets gave 0 warnings. clippy -W clippy::pedantic gives 12 warnings on lines this PR adds or changes: 7 doc_markdown, 4 needless_pass_by_value in test helpers and 1 similar_names.
  • Wire tests on a debug SQLite server (--no-default-features --features sqlite). tests/test_scan_checks_before_authorization.py passes: its 19 rows answer the service's error code to a user allowed only DescribeTable, and the valid body answers AccessDeniedException. tests/test_query_scan.py, test_partiql_item_depth.py, test_query_key_value_types.py, test_query_value_shapes.py, test_query_leading_keys_values.py, test_scan_number_values.py and the authorization file gave 555 passed and 3 xfailed. tests/python/test_scan_request_validation.py, test_scan_request_rows.py, test_scan_range_constraints.py, test_scan_range_constraints_beside_values.py, test_scan_edge_cases.py and test_query_scan.py gave 408 passed and 3 xfailed.
  • The six test files this PR changes on a MongoDB server (--no-default-features --features mongodb, a mongo:7 replica set on 127.0.0.1): 431 passed, 6 xfailed. The xfail rows are the three of test_scan_request_rows.py and the three of test_partiql_item_depth.py.
  • pytest --collect-only collects 7349 tests in tests/ and 1031 in tests/python/, with no error.
  • Controls, each on the committed tree with one fix's old lines put back. With the 32-level bound, 3 unit tests fail. With no depth check in ExpressionValuesBody, 1 fails. With first_fault in place of hashed_members in StartKeyBody::validate, a_shape_fault_in_a_key_value_answers_the_prefixed_text fails on the build without the MongoDB crate: {"M": {"q": {"N": "bob"}, "b": {}}} answers the empty value where bob is expected. With validate_before_authorization running the request checks alone, as before 316ea8e95, the eight new rows of the authorization file answer AccessDeniedException on a SQLite server. Four of the earlier rows do too.
  • 5257ed892 is a pure move. A line-by-line comparison of the commit finds no other added or dropped line. The exceptions are the file header, the module doc, the mod and use lines, and the field visibility.

At 1bdcf89b0:

  • cargo +1.97.0 test --locked -p extenddb-engine --lib: 965 passed.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy --locked -p extenddb-engine -p extenddb-server --all-targets -- -D warnings gave 0 warnings, with and without --features extenddb-engine/backup-test-hooks. cargo +1.91.1 check --locked -p extenddb-engine -p extenddb-server --all-targets gave 0 warnings. clippy -W clippy::pedantic gives no warning on the lines of these two commits, and the same 15 on the lines of the PR as below.
  • Wire tests on a debug SQLite server (--no-default-features --features sqlite). tests/test_scan_checks_before_authorization.py passes: its nine rows answer ValidationException to a user allowed only DescribeTable, and the valid body answers AccessDeniedException. At 34fe82848 it failed in four pytest jobs of CI, on the Select row and the unknown type descriptor row. With tests/test_scan_number_values.py it gave 90 passed. tests/test_query_scan.py, test_partiql_item_depth.py, test_query_key_value_types.py, test_query_value_shapes.py, test_query_leading_keys_values.py and the authorization file gave 466 passed and 3 xfailed. tests/python/test_scan_request_validation.py, test_scan_request_rows.py, test_scan_range_constraints.py, test_scan_edge_cases.py and test_query_scan.py gave 393 passed and 3 xfailed.
  • pytest --collect-only collects 7334 tests in tests/ and 1016 in tests/python/, with no error.

At fafd29b61:

  • cargo +1.97.0 test --locked -p extenddb-engine --lib: 965 passed. The Scan checks have 46 unit tests: 13 in scan_request/range_tests.rs, 8 in scan_request/tests.rs, 12 in request_tests.rs, 8 in key_tests.rs and 5 in holder_tests.rs.
  • The 84 unit tests of scan_request, query_key_values and int32_member also pass with serde_json/preserve_order on, in a build with extenddb-storage-mongodb.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy --locked -p extenddb-engine --all-targets -- -D warnings gave 0 warnings, with and without --features extenddb-engine/backup-test-hooks, as clippy.yml runs it. cargo +1.91.1 check --locked -p extenddb-engine --all-targets gave 0 warnings. clippy -W clippy::pedantic on the engine gives 15 warnings on lines this PR adds: 9 doc_markdown, 4 needless_pass_by_value in test helpers, 1 similar_names and 1 too_many_lines on the Scan handler.
  • Wire tests on a debug SQLite server. tests/python/test_scan_request_validation.py and test_scan_request_rows.py hold 245 tests: 242 passed, and 3 are xfail (the two ScanFilter number rows for fix(query): check legacy conditions against the key schema #507, the value count text for Scan: the Segment, ScanFilter value count and COUNT with AttributesToGet checks answer texts that differ from the service #838). With test_scan_range_constraints.py, test_scan_edge_cases.py and test_query_scan.py in tests/python/, 393 passed and 3 xfailed.
  • The two wire files of this PR and test_scan_range_constraints.py on a MongoDB server (--features mongodb, a mongo:7 replica set, EXTENDDB_TEST_BACKEND=mongodb as devtools/run-tests --backend mongodb sets it): 341 passed, 3 xfailed.

At ae4fa32bf. Its production code differs from fafd29b61 only in the order it reads the members of an M. A build without the MongoDB crate sorts a parsed map, so there the two read them in the same order:

  • cargo +1.97.0 test --locked -p extenddb-core --lib: 1147 passed, 1 ignored.
  • Wire tests on a debug SQLite server: tests/test_scan_number_values.py, test_query_scan.py, test_partiql_item_depth.py, test_query_key_value_types.py and test_query_value_shapes.py gave 552 passed and 3 xfailed.
  • devtools/test-shards check on three legs of the --comprehensive suite, prepared with devtools/test-shards prepare: 1016 tests, 327 + 326 + 363.
  • cargo +1.97.0 clippy --all-targets -- -D warnings gave 0 warnings on extenddb-storage-postgres, extenddb-storage-sqlite and extenddb-server too, and cargo +1.91.1 check --locked -p extenddb-storage-postgres --all-targets gave 0 warnings.

Controls. Each puts back the old lines of one fix on the committed tree, and the unit tests then fail:

  • the ScanFilter list taking only a value the service cannot read: 1 test
  • a key member's unreadable value ahead of its numbers and sets: 1 test
  • no AttributesToGet clause in the older form: 2 tests
  • no value_shape_fault ahead of the checks: 1 test
  • the table sized by the count of names alone: 1 test
  • the members of an M in sorted order, as 6d2c7795c read them, in the preserve_order build: 1 test. a_shape_fault_in_a_key_value_answers_the_prefixed_text then answers the empty value text for the key member {"M": {"k": {"N": "bob"}, "j": {}}}, where that build expects bob. A build without the MongoDB crate passes with either order

A SQLite server built with the first five fails 10 of the 15 rows of 2026-11-23. They are the three AttributesToGet rows, both list rows, the key row, the nine and ten names, and two of the three shape rows. The other five pass there as well. The two enum rows come from the base's builder, and the eight names do not double the table. The empty name row keeps the merge's order, and "Limit": "5" is the base's shape fault check.

A MongoDB server built with the sort put back answers the number text for fred for both z and b rows, on Scan and on Query. It fails the wire row of the key member. The MongoDB server of fafd29b61 answers bob and the empty value text, as the service does on Scan.

A Scan with 40,000 ExpressionAttributeValues entries (908,994 bytes) went to debug SQLite servers, five sends each. It took 6.98 to 7.82 s on 2e3e4996d and 0.72 to 0.79 s on 9bbf50ef3.

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.

…key numbers and nesting

Measured against the service on 2026-10-25 at 10:38 and 10:55 UTC, each
request sent twice (#564, items 1, 2, 4 and 5):

- An empty ScanFilter counts as present for the expression and
  non-expression parameter mix. ScanFilter {} with a FilterExpression
  answers the mix text; ScanFilter {} alone is accepted.
- AttributesToGet [] answers "1 validation error detected: Value at
  'AttributesToGet' failed to satisfy constraint: Member must have length
  greater than or equal to 1", alone, with a FilterExpression, and with a
  FilterExpression and a malformed number, so it comes ahead of the
  number check.
- A malformed N in ExclusiveStartKey answers "The parameter cannot be
  converted to a numeric value: <text>".
- An ExpressionAttributeValues value nested 32 or more L levels deep
  answers "Nesting Levels have exceeded supported limits: Attributes in
  the item have nested levels beyond supported limit". 31 levels pass.

ExtendDB accepted the first two, answered the starting-key schema text
for the third, and had no nesting check on Scan. The request-time checks
in crates/engine/src/scan_request.rs now make the four checks in the
order the module doc lists. M levels count the same as L levels; only L
was measured with a valid number at the bottom.

Unit tests are in crates/engine/src/scan_request/request_tests.rs.
tests/python/test_scan_request_validation.py has 18 rows; it passes on
SQLite and PostgreSQL servers built from this branch, and 9 of the 18
fail on a server built from the #563 branch, which this one is stacked on.

One row of item 5 stays open. From 63 L levels the service answers
"ExpressionAttributeValues contains invalid value: Nesting Levels have
exceeded supported limits: Attributes in the item have nested levels
beyond supported limit for key :d" (measured 2026-10-30 at 63, 70, 80,
99 and 100 levels; 32 to 62 levels answer the bare text), and ExtendDB
answers SerializationException from the JSON parser, whose recursion
limit is 128 levels, 62 of them L wrappers. That is a change to request
parsing for every operation, not to the Scan checks, and is filed on its
own. Item 3, the legacy AttributeValueList numbers, is #507's.

Refs #564
Measured against the service on 2026-10-30 at 12:40 UTC, each request
sent twice, as a raw signed Scan:

- Limit 0 with AttributesToGet [] answers "2 validation errors detected:
  Value at 'AttributesToGet' failed to satisfy constraint: Member must
  have length greater than or equal to 1; Value at 'Limit' failed to
  satisfy constraint: Member must have value greater than or equal to
  1". The length constraint is one of the constraints the service
  aggregates into one message, listed ahead of Limit. The check reported
  the Limit fault alone and never reached the length check.
- AttributesToGet [] with ScanFilter {} and a FilterExpression answers
  the length clause alone, so the aggregated constraints come ahead of
  the parameter mix.
- A malformed N in ExclusiveStartKey with no filter, and in the index
  key of a GSI scan, answers "The parameter cannot be converted to a
  numeric value: bob"; with ReturnConsumedCapacity BAD as well, the enum
  text alone.
- An L nested 32 levels with Select BAD answers the nesting text, so the
  nesting check comes ahead of the Select enum.

The length check joins the range check, and the module doc, the comment
at the top of handle_scan and the tests cite the measured orders. Where
the length clause sits beside a Segment or TotalSegments fault alone,
and its older form, are not measured: the code lists it first in the
newer form, as beside Limit, and last in the older form with the empty
list echoed, as the older form reverses the newer one. Both are in the
unit test of requests the service was not sent.

tests/python/test_scan_request_validation.py has 24 rows: the six new
ones send the measured requests above, and the table gains a GSI for
the index-scan row.

Refs #564
Measured against the service on 2026-10-31 between 23:54 and 23:56 UTC,
each request sent twice, as a raw signed Scan with {"pk": {"N": "bob"},
"sk": {"S": "x"}} as the ExclusiveStartKey:

- Every other check comes ahead of the key's number: the Limit, Segment
  and AttributesToGet constraint clauses, the ReturnConsumedCapacity and
  Select enum clauses, the Select rule for SPECIFIC_ATTRIBUTES, the
  parameter mix, the nesting text, the FilterExpression syntax error and
  the unused-value text each answer their own text, and a malformed number
  in ExpressionAttributeValues is reported ahead of one in the key. The
  check ran at request time, between the value numbers and the nesting
  check, so the Select enum, the nesting text, the SPECIFIC_ATTRIBUTES
  rule, the filter syntax and the unused value lost to the key's number.
- Inside the key a number fault comes ahead of an empty value or an
  unknown type descriptor, in either member order, and a number nested
  in the L of an attribute that is not a key attribute counts: {"pk": {},
  "sk": {"N": "bob"}} answers The parameter cannot be converted to a
  numeric value: bob. The typed deserialization of the body reported the
  empty value first, with the deserializer's text.
- A key whose only fault is an empty value answers The provided starting
  key is invalid: Supplied AttributeValue is empty, must contain exactly
  one of the supported datatypes. The deserializer's text had no prefix.

The handler now takes the key out of the body before the typed
deserialization when its values do not deserialize for a reason other
than a shape fault, and checks the key at its own stage, right before the
key schema: every number in it, in the sorted order of its members, with
the value check's rules and text, then the deserializer's fault with the
service's prefix. A key of the wrong JSON shape stays in the body and is
reported first, as before. Not measured: the key against the table
lookup, the index resolution, the index rules and the Segment pairing,
which the handler checks ahead of it; an unreadable-only key against the
filter syntax and unused-value checks; the prefix on the deserializer's
texts for two type descriptors and for an empty or duplicate set; and
which of two number faults is named when the request lists the members
the other way round (sorted order names bob either way).

The unit test that applied the checks' order to rows the service had not
been sent is renamed: all seven of its rows were sent on 2026-10-31 and
answered as asserted.

request_tests.rs has the measured rows, and
tests/python/test_scan_request_validation.py sends them as raw signed
requests: seven rows for the other checks ahead of the key, the nesting
text, the SPECIFIC_ATTRIBUTES rule and the filter syntax ahead of it,
nine rows for the faults inside the key, and three number texts on an N
hash key. The parser here words the filter syntax error differently from
the service, and the Scan text for the SPECIFIC_ATTRIBUTES rule has no
"1 validation error detected" prefix here, so those two tests assert the
check's place and not the text.
Measured against the service on 2026-11-05, each request sent twice, as a
raw signed Scan: a check of each stage beside each class of key fault, each
key alone, and pairs of faulty members on three tables.

- A key value that is empty, carries an unknown or lower-case type
  descriptor or carries two descriptors, at its top or inside an L or M, in
  a key member or in another member, is reported after the request
  parameter checks (ExpressionAttributeValues or ExpressionAttributeNames
  with no expression, ConditionalOperator with no ScanFilter, a ScanFilter
  condition's value count, the parameter mix) and ahead of the expression
  checks, with the prefix The provided starting key is invalid: on the
  empty-value or more-than-one-datatypes text. An unknown descriptor
  answered the deserializer's SerializationException; the other shape
  faults answered after the expression checks.
- A number that does not parse and the set faults are reported after the
  expression and request checks (the filter syntax, an undefined value, the
  operand types, the projection syntax, the Select rules, the unused
  values, the Segment pairing) and ahead of the table lookup, with no
  prefix: The parameter cannot be converted to a numeric value: bob; One or
  more parameter values were invalid: An number set  may not be empty, An
  string set  may not be empty, Binary sets should not be empty; Input
  collection contains duplicates. for an NS, also for ["1", "1.0"]; Input
  collection ["a", "a"] contains duplicates. for an SS. The set texts
  carried the key prefix, the NS duplicate text listed the members, and
  the key's number came after the table lookup and the index checks.
- A value of ExpressionAttributeValues the deserializer refuses (an empty
  value read by the filter) is reported after the key's value faults and
  ahead of the table lookup. It was reported ahead of every handler check.
- With faults in two members the service names one of them by the
  attribute names and, on some tables, the request's order: {"pk": {},
  "sk": {"N": "bob"}} answered the number on 2026-10-31 and {"a": {}, "b":
  {"N": "bob"}} the empty value. The code reports a shape fault in any
  member ahead of a value fault in any member, then the members in sorted
  order, and no test pins which member.

The handler holds back a key or an ExpressionAttributeValues value the
deserializer refuses, checks the key's shape faults between the request
parameter checks and the filter parse, and checks its numbers and sets,
then the held-back value, right before the table lookup. The Segment
pairing, the filter's placeholder and operand checks and the Select COUNT
rule for AttributesToGet move ahead of the key's value stage from after the
table lookup, as the measured rows beside a number in the key need. The
nesting check keeps its request-time place: the service answered the key's
text for a nested value the filter reads beside a key shape fault, and the
nesting text ahead of the Select enum for an unused value, which one order
cannot both give.

Not measured: a BS with duplicates, a number and a duplicate in one NS, a
set member that is not a string, an ExpressionAttributeValues value refused
for a reason other than an empty value, and the nesting check beside a key
shape fault for an unused value.

request_tests.rs has the measured rows, and
tests/python/test_scan_request_validation.py sends them as raw signed
requests: each stage beside each class of key fault, each key alone, the
pairs of faulty members (either member's fault accepted), the Segment
pairing, an undefined filter value, a missing table and an empty
expression value beside the key. The SPECIFIC_ATTRIBUTES rule and the
filter syntax tests assert only the check's place, as the texts differ
from the service's on main.
The service checks a Scan request in one of two orders. A value that is
not one AttributeValue is empty, has an unknown or lower-case type
descriptor, or has two descriptors. The fault can sit at the top or
inside an L or M. A request with such a value in ExpressionAttributeValues,
ExclusiveStartKey or a ScanFilter list follows order U. Every other
request follows order R. The same test
picks the older form of the constraint clauses. Measured against
DynamoDB (us-east-1) on 2026-10-31 and 2026-11-05, each request twice.

Order R:

- The constraint clauses in the newer form, then the ReturnConsumedCapacity
  enum, which comes ahead of the parameter mix. Then the mix, the numbers
  in ExpressionAttributeValues and their nesting depth. The nesting check
  comes ahead of the no-expression check (B4-7, 2026-10-31).
- An empty or duplicate set in ExpressionAttributeValues, ahead of the
  no-expression check.
- The request parameter checks: ExpressionAttributeNames with no
  expression, ExpressionAttributeValues with no expression,
  ConditionalOperator with no ScanFilter, a ScanFilter condition's value
  count. Then the Select enum.
- The expression checks: the filter syntax, the projection syntax, an
  undefined value, the operand types and the Select rules. Then the
  unused values, COUNT with a ProjectionExpression, COUNT with
  AttributesToGet and the Segment pairing.
- The key's number and set faults, then the table and its indexes.

Order U:

- The constraint clauses in the older form, then the ReturnConsumedCapacity
  and Select enums. Then the mix and the other request parameter checks.
- The key's faults, shape and value together: the first faulty member in
  the member order below. A shape fault carries the prefix The provided
  starting key is invalid: on the empty-value or more-than-one text. A
  number carries the value check's text.
- The ExpressionAttributeValues entries the deserializer refuses, read or
  not, with the text ExpressionAttributeValues contains invalid value: ...
  for key :e. An unknown descriptor answers the empty-value text there.
- The nesting depth, then the expression checks and the table.

The member order inside ExclusiveStartKey is fitted to 112 measured rows
on five tables. It is the order of a Java HashMap of capacity 4 over the
member names. String.hashCode() of the name is spread as h ^ (h >>> 16)
and masked to four buckets. The buckets come in ascending order, and the
request's order holds inside a bucket. sk falls in bucket 0, a in 1, b in
2, pk, gpk, id and ts in 3. The parsed body sorts object members on every
build but the MongoDB one. dispatch now passes the request text on, and
the handler reads the request's member order from it. Two value faults in two members vary
between sends on the service. The tests for those accept either answer.

The set texts follow the order. Order R quotes the members: Input
collection ["a", "a"] contains duplicates. and Input collection
["YQ==","YQ=="]of type BS contains duplicates. Order U does not: Input
collection [a, a] contains duplicates. For an NS in order U the text is
Input collection contains duplicates, with no prefix and no full stop.
An empty SS in the key carries the key prefix in order U.

Before this change the key's shape faults came at one stage and its value
faults at another in every request. The unreadable
ExpressionAttributeValues entries came after the key's value faults
whether or not an expression read them. The Select enum was a
request-time check in every request.
Row B4-7 of 2026-10-31 (an unused empty value beside a nested value)
answered the unused-value text instead of the empty value's.

Not measured, and kept in the code's order. In order R, the nesting check
against ExpressionAttributeNames with no expression, ConditionalOperator
and the ScanFilter value count. A set fault in ExpressionAttributeValues
against the nesting check. In order U, the Select enum against the mix. A
malformed ExpressionAttributeValues number against the key's faults. An
empty BS or a BS with duplicates in the key. An empty SS in the key beside
an unreadable expression value. Which entry is named when several
ExpressionAttributeValues entries are faulty: the first in sorted order.
Keys of four members follow the same member order.

The texts of #722 (the no-expression suffix), #832, #838 and #839 do not
change here.

Tests: request_tests.rs covers the order flag, the texts of each order,
the member order and its buckets, and what the handler holds back.
tests/python/test_scan_request_validation.py sends 161 rows as raw signed
JSON, among them B4-7, the R5 rows of 2026-11-05 and the member-order rows
on four tables. 41 of them fail on the previous commit.
…he service does

Measured against DynamoDB (us-east-1) on 2026-11-05 at 05:31, 06:20 and
07:38 UTC, each request twice.

- In order U a ScanFilter list value that is not one AttributeValue
  answers Supplied AttributeValue is empty, must contain exactly one of
  the supported datatypes. The text has no prefix. {} and an unknown
  descriptor answer alike. Two descriptors answer the more-than-one
  text. The step comes after the no-expression checks. It comes
  ahead of ConditionalOperator, the lists' value counts, the key's
  faults and the table. The conditions are visited in the order of the
  key's members and each list in its order. The handler holds such a
  value back from the typed deserialization, which reported it with
  the deserializer's text.
- In order U the ExpressionAttributeValues entries are visited in the
  order the key's members are visited. A malformed number, a set fault
  and a value that is not one AttributeValue are reported at the map's
  step, after the key's faults. Each takes the form
  ExpressionAttributeValues contains invalid value: <text> for key :a.
  The number text is The parameter cannot be converted to a numeric
  value: bob. It applies at the top of the entry and inside its L or
  NS. The set texts are those of order U. Inside one entry the first fault in the
  value's element order is named. A number ahead of an empty value
  answers the number.
- In order R the request-time number check visits the entries in the
  same order as the key's members. Two malformed numbers answer the one
  in the lower bucket, not the lower name. The set faults are checked
  at request time too, after the numbers and ahead of the nesting
  depth, in sorted name order on every backend. The service answered
  each of two set faults in one of its two sends.
- The visiting order of the key's members and of the map's entries is
  the iteration order of a Java HashMap. The map starts with four buckets
  and doubles when it holds more than three quarters of its size. Up to
  three names get four buckets, four to six names get eight, seven to
  twelve get sixteen. A key of four members on a GSI with a range key
  names gpk and pk ahead of gsk, which four buckets would reverse. Keys
  of five and seven members and maps of four and seven entries follow
  the same rule. Names outside ASCII hash on their UTF-16 code units,
  a supplementary-plane name on its two. Two names in one bucket keep
  the request's order. The handler reads the request's order of the key
  members, the map's entries and the ScanFilter conditions. It reads
  them from the request text.
- An empty BS in the key carries the key prefix in order U, as the empty
  SS does. It does so beside an unreadable key member or expression
  value, inside an L, and in a member that is not a key attribute. The
  empty NS does not.
- In order R the request-time number and nesting checks read the entries
  that deserialize one by one. A set fault in one entry no longer skips
  the numbers of the others. A malformed number inside an entry the
  deserializer refuses is reported after the nesting depth of another
  entry.

Left to PR #507 (#564 item 3): a malformed number in a ScanFilter list.
The service answers The parameter cannot be converted to a numeric
value: bob, ahead of a number in the key (2026-11-05). This commit does
not check the lists' numbers. The ComparisonOperator enum clause the
service answers in order U is a legacy-condition check too and is not
made here.

Not measured, and kept in the code's order: an empty value ahead of a
malformed number inside one ExpressionAttributeValues entry. The code
names the empty value, the element order. A set fault in a ScanFilter
list value in order U. A set fault beside a malformed number in another entry of
ExpressionAttributeValues in order R, where the service's two sends
disagreed. Nine or more names in one hash bucket, where Java's HashMap
doubles a table under 64 buckets early and the code does not.

Tests: request_tests.rs covers the ScanFilter step of order U and the
map's order and invalid-value form in order U. It covers the two orders
of the request-time number and set checks and the element order inside
one entry. It covers the table's doubling and the request order read from
the text. The wire file sends 69 of the 73 rows of 2026-11-05, two of
them with the nested value written out. It has 230 tests. The two
ScanFilter number rows are marked xfail for #507. Three rows accept
either of two service answers. Thirty-nine of the others fail on the
previous commit.
…kup tests

Main adds three dispatch calls to the SQLite backup tests (#700), and this
branch adds the raw_body argument to dispatch. The calls now pass an empty
raw body, because only Scan reads it and these calls do not send a Scan.
…e test

Main adds the SQLite restore test (#740), which calls dispatch with four
arguments, and this branch adds the raw_body argument to dispatch. The
call now passes an empty raw body. Only Scan reads the raw body, for the
request order of the members of ExclusiveStartKey,
ExpressionAttributeValues and ScanFilter. With an empty raw body, the
Scan checks use the order of the parsed body. The order sets which fault
the Scan reports first. The Scan calls in this test send no faults. Each
one sends TableName and Select, with IndexName for an index and, after
the first page, the LastEvaluatedKey of the previous page as
ExclusiveStartKey.
The doc comment of dispatch said that Scan reads the member order of
ExclusiveStartKey from raw_body. handle_scan also reads the member order
of ExpressionAttributeValues and ScanFilter from it.
Main adds PartiQL SELECT (#411), which builds a Scan body and calls
handle_scan with two arguments, and this branch adds the raw_body
argument to handle_scan. The call now passes an empty raw body. Scan
reads the raw body only for the request order of the members of
ExclusiveStartKey, ExpressionAttributeValues and ScanFilter. With an
empty raw body, the parsed body's member order stands in for the
request's order. The order sets which fault the Scan reports first.
PartiQL builds this body itself, so no request text exists for it. The
body holds TableName and, when the statement or the request gives them,
FilterExpression, IndexName, ExpressionAttributeNames,
ExpressionAttributeValues, Limit, ExclusiveStartKey, ConsistentRead and
ReturnConsumedCapacity. It never holds ScanFilter.
This branch adds a nesting check on the ExpressionAttributeValues
entries of a Scan. It refuses an entry nested 32 levels deep, as the
service does for a Scan request. PartiQL SELECT builds a Scan body for
a statement with no key condition, and it puts each parameter into
ExpressionAttributeValues. So the check also refused a 32-level
parameter in the WHERE clause of such a SELECT.

The service accepts that parameter. On 2026-11-09 in us-east-1,
SELECT * FROM "t" WHERE a <> ? returned the items for a parameter of
32 maps and refused 33 maps with the nesting message. A Scan with the
FilterExpression a <> :v refused 32 maps.

handle_scan keeps every check of a Scan request. PartiQL SELECT now
calls handle_partiql_scan, which runs the same checks and the same
read, except the nesting check on ExpressionAttributeValues, in both
orders. The PartiQL parameter check still refuses 33 levels before the
engine reads the statement.

A unit test runs the request-time checks with the depth checked and
with it unchecked. Two wire tests in test_partiql_item_depth.py send a
SELECT that reads the whole table, with 32 and with 33 levels.
@demohan demohan self-assigned this Nov 12, 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.

Measured against DynamoDB in us-east-1 on 2026-11-12, each request sent at least twice, and against servers built from 2e3e499. The inline comments carry the requests and answers. I will approve once these items are done:

  1. The enum clauses share one message with the older-form constraint clauses (scan_request.rs:255). #850 answers these rows the same way and needs the same fix.
  2. An empty or duplicate set in a ScanFilter list is reported at the list step, after the shape and number checks (scan_request.rs:1077).
  3. A wrong JSON type anywhere in the body answers SerializationException first, before any value is replaced (scan_request.rs:1007, scan_request.rs:615, query_key_values.rs:101).
  4. The member order work is linear in the member count (scan_request.rs:433).
  5. Members of an M are visited in the service's order, the same on every backend (scan_request.rs:816).
  6. Element order inside one key member and one ScanFilter list (scan_request.rs:657, scan_request.rs:1077).
  7. The bucket table at nine names in one bucket (scan_request.rs:529).
  8. Rows that accept either of the two answers the service gives (test_scan_request_validation.py:622).
  9. The service's escape form in the duplicate set texts (scan_request.rs:743).
  10. selR-arity-select-bad expects the text the service sends (test_scan_request_validation.py:585).

Smaller points:

  • scan_request.rs grows from 236 to 1263 lines, request_tests.rs is new at 1302 and test_scan_request_validation.py is new at 1092. A split by concern (member order, value fault texts, the four holders) works as pure moves.
  • The sort at scan_request.rs:346 fails no test under cargo test -p extenddb-engine, where bson does not turn on preserve_order. On MongoDB the sort is what keeps the answers equal across backends.
  • The new module fixtures create the table and seed it before yield with no try/finally, so a failure in wait_for_active or put_item leaves the table behind. _two_member_table does the same.
  • The description gives 688 engine and 1062 core tests. The head runs 704 and 1084.

Comment thread crates/engine/src/scan_request.rs Outdated
values_order: Option<&[String]>,
depth: ValuesDepth,
) -> Result<(), DynamoDbError> {
validate_constraints(body, order)?;

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.

When the constraint clauses take the older form, the service puts the enum clauses in the same message. {"Select": "BAD", "ReturnConsumedCapacity": "BAD", "FilterExpression": "a = :a", "ExpressionAttributeValues": {":a": {}}} answers 2 validation errors detected: Value 'BAD' at 'select' failed to satisfy constraint: ...; Value 'BAD' at 'returnConsumedCapacity' failed to satisfy constraint: ... (us-east-1, 10 sends). This branch answers the returnConsumedCapacity clause alone. "Limit": 1.5, "Limit": 3000000000 and "Segment": 0.5 with both enums do the same. main answers these four rows as the service does. With six faults the service orders the clauses select, totalSegments, returnConsumedCapacity, segment, limit, attributesToGet. The split is already on the base branch.

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.

Fixed in 5eb0132, with the rows in 7496c20. The merge uses the base's older-form builder, older_form_request_checks in query_key_values/unreadable.rs, from the fix round of #850. It puts the select and returnConsumedCapacity clauses in one message with the range clauses, in the order select, totalSegments, returnConsumedCapacity, segment, limit. This branch's separate Select check in order U is gone, and the builder now adds the attributesToGet clause last. Order R keeps its own ReturnConsumedCapacity check, which the service makes ahead of the parameter mix there (2026-11-05).

I sent the rows again on 2026-11-23, twice each. Both enums beside {":a": {}} and beside "Limit": 1.5 answered 2 validation errors detected: Value 'BAD' at 'select' ...; Value 'BAD' at 'returnConsumedCapacity' ... (14:03 UTC). AttributesToGet: [], Limit: 0.0, Segment: -1 and TotalSegments: 1000001 beside both enums answered the six clauses in your order (21:49 UTC). The wire rows are d1-select-rcc-unreadable, d1-limit-float-both-enums and A1 to A3 in tests/python/test_scan_request_rows.py, and the unit rows are in the_enum_clauses_sit_inside_the_older_form_message. A local server of this head answers "Limit": 3000000000 and "Segment": 0.5 beside both enums with the same two clauses.

Comment thread crates/engine/src/scan_request.rs Outdated
continue;
};
for value in values.iter_mut() {
if let Some(text) = shape_fault(value) {

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.

Only shape faults are taken out here. An empty or duplicate set in a list value stays in the body, and serde_json::from_value::<ScanInput> reports it first. "AttributeValueList": [{}, {"NS": []}] answers Supplied AttributeValue is empty, must contain exactly one of the supported datatypes on the service (10 sends) and on main. This branch answers An number set may not be empty. Beside ExpressionAttributeNames with no expression, the service answers the no-expression text. A number ahead of a shape fault is also skipped: [{"N": "bob"}, {}] answers The parameter cannot be converted to a numeric value: bob on the service (2 sends). The list needs one walk in element order over shapes, numbers and sets.

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.

Fixed in 5eb0132, with the rows in 7496c20. ScanFilterBody::take, now in scan_request/holders.rs, walks each list once in element order with first_fault. That walk finds a value the service cannot read, a malformed number and a set fault. The holder takes out every faulty value and reports the first.

On 2026-11-23 (14:03 UTC, twice each) [{}, {"NS": []}] answered the empty value, and [{"N": "bob"}, {}] answered The parameter cannot be converted to a numeric value: bob. Both are wire rows (d2-sf-empty-then-NSe, d2-sf-bob-then-empty) and unit rows in a_scan_filter_list_value_is_checked_at_its_step. That unit test fails with the list check put back to shape faults only. Beside ExpressionAttributeNames with no expression, a local server of this head answers the no-expression text.

Comment thread crates/engine/src/scan_request.rs Outdated
}
};
if let Some(fault) = fault {
*value = serde_json::json!({"S": ""});

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 stand-in replaces the whole entry, so a wrong JSON type inside it is never deserialized. {":a": {"L": [{"S": 5}, {}]}} answers SerializationException: NUMBER_VALUE cannot be converted to String on the service (2 sends). main answers a SerializationException. This branch answers ExpressionAttributeValues contains invalid value: Supplied AttributeValue is empty, ... for key :a. The same happens at line 1078 for [{"L": [{"S": 5}, {}]}] in a ScanFilter list. A pass that finds a wrong JSON type anywhere in the body before any stand-in would cover both.

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.

Fixed in af5e023. value_shape_fault in query_key_values/unreadable.rs deserializes each ExpressionAttributeValues entry, each ExclusiveStartKey value and each ScanFilter list value on its own, with the parts the service cannot read replaced. request_checks runs it ahead of every other check, so the pass reads a value before any stand-in replaces it.

{":a": {"L": [{"S": 5}, {}]}} answered SerializationException: NUMBER_VALUE cannot be converted to String on 2026-11-23 (14:03 UTC, twice). This head answers SerializationException for it (row d3-eav-L-S5-empty), and for the list [{"L": [{"S": 5}, {}]}] on a local server. The deserializer's text differs from the service's, and the description lists that under Known differences. Without the pass, a_value_of_the_wrong_json_type_is_found_behind_a_value_fault fails.

Comment thread crates/engine/src/scan_request.rs Outdated
.map(|key| serde_json::from_value::<Item>(key.clone()))
{
Some(Err(e)) => match crate::deserialize_error(e) {
shape if is_shape_fault(&shape) => None,

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 key is classified by the deserializer's first error. {"pk": {"NS": []}, "sk": {"S": 5}} answers a SerializationException on the service in either member order (2 sends each). This branch answers An number set may not be empty. {"pk": {}, "sk": {"N": 5}} answers the prefixed empty-value text here, where the service answers a SerializationException.

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.

Fixed in af5e023, by the pass of thread 3. value_shape_fault reads each key value on its own ahead of the checks. A value fault in one member no longer hides a wrong JSON type in another.

{"pk": {"NS": []}, "sk": {"S": 5}} answered SerializationException: NUMBER_VALUE cannot be converted to String on 2026-11-23 (14:03 UTC, twice). This head answers SerializationException for it (row d4-key-NSe-S5), and a local server gives the same for the other member order. {"pk": {}, "sk": {"N": 5}} now answers SerializationException too. The reviewed head answered the prefixed empty-value text.

Comment thread crates/engine/src/query_key_values.rs Outdated
shape @ DynamoDbError::SerializationException(_) => shape,
_ => check,
},
Err(e) => {

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 reads only the first serde error, so a value fault that sorts first hides a wrong JSON type later in the body. {"AttributesToGet": [], "ExclusiveStartKey": {"pk": {"NS": []}}, "Limit": "5"} answers SerializationException: STRING_VALUE cannot be converted to Integer on the service (2 sends). This branch answers the AttributesToGet length clause. {":a": {"NS": []}, ":b": {"S": 5}} answers the empty-set text here.

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.

Fixed. shape_fault_first now reads each member of the body on its own (d7e6ff3, from the fix round of #544, which the base carries). The merge (5eb0132) brings it in. The key's ValidationException no longer stops it before "Limit": "5". {"AttributesToGet": [], "ExclusiveStartKey": {"pk": {"NS": []}}, "Limit": "5"} answered SerializationException: STRING_VALUE cannot be converted to Integer on 2026-11-23 (14:03 UTC, twice), and this head gives the same text (row d5-atg-NSe-limit-string).

For a wrong JSON type inside a value, value_shape_fault (af5e023, thread 3) runs first. {":a": {"NS": []}, ":b": {"S": 5}} answers SerializationException on a local server of this head.

Comment thread crates/engine/src/scan_request.rs Outdated
/// Returns `DynamoDbError::ValidationException` with the service's text.
pub(crate) fn validate(&self, order: CheckOrder) -> Result<(), DynamoDbError> {
for (_, value) in self.members() {
if order == CheckOrder::Unreadable

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 shape pass covers the whole member before the value pass, so a shape fault after a number wins. {"pk": {"L": [{"N": "bob"}, {}]}, "sk": {"S": "s"}} answers The parameter cannot be converted to a numeric value: bob on the service (2 sends). This branch answers The provided starting key is invalid: Supplied AttributeValue is empty, .... ExpressionValuesBody uses element order for the same value.

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.

Fixed in 5eb0132, with the row in 7496c20. StartKeyBody::validate now takes each key member's first fault with first_fault, in the member's element order, and puts the key prefix on a value the service cannot read.

{"pk": {"L": [{"N": "bob"}, {}]}, "sk": {"S": "s"}} answered The parameter cannot be converted to a numeric value: bob on 2026-11-23 (14:03 UTC, twice), and this head gives the same text. It is the wire row d8-key-L-bob-empty and a unit row in a_shape_fault_in_a_key_value_answers_the_prefixed_text, which fails with the old shape pass put back.

Comment thread crates/engine/src/scan_request.rs Outdated
/// The bucket mask of a Java `HashMap` that starts with four buckets and
/// doubles whenever it holds more than three quarters of its size: 3 for up to
/// three names, 7 for four to six, 15 for seven to twelve, and so on.
fn hash_table_mask(names: usize) -> u32 {

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 table is sized by the name count alone. With nine ExpressionAttributeValues names in one of sixteen buckets, :aa and :dt empty, the service names :dt (10 sends) and this branch names :aa. Ten names give the same result. The table also grows when one bucket reaches nine names.

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.

Fixed in af556dd. hash_table_mask now puts the names in the request's order. It doubles the table when it holds more than three quarters of its size. It also doubles it when a put makes one bucket hold nine names while the table has fewer than 64 buckets, as HashMap.treeifyBin does.

I sent your rows on 2026-11-23 (21:49 UTC, twice each), with :aa first and :dt last, both empty. Eight names in bucket 10 of 16 named :aa, and nine and ten names named :dt. In a table of 32 buckets :dt sits in bucket 10 and the others in bucket 26. The rows are H8 to H10 in tests/python/test_scan_request_rows.py, with unit rows in the_fitted_member_order_follows_the_hash_buckets_then_the_request. That test fails with the old sizing.

In Java, a bucket that reaches nine names in a table of 64 buckets or more becomes a tree. That moves one of its names to the front. The code keeps the request's order there, and the description lists that as not measured.

Comment thread crates/engine/src/scan_request.rs Outdated
members
.iter()
.map(|member| match order {
CheckOrder::Readable => serde_json::to_string(member).unwrap_or_default(),

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 service does not escape set members with JSON escapes. {"SS": ["a\u0001", "a\u0001"]} answers Input collection ["a\u{1}", "a\u{1}"] contains duplicates. (2 sends). This branch answers ["a\u0001", "a\u0001"]. \u007f and \u200b come back as \u{7f} and \u{200b}, and \u0000 as \0. This branch returns the raw characters for the first two.

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.

Agreed, the form differs, and this PR does not change it. I sent three rows on 2026-11-23 (14:03 UTC, twice each). {"pk": {"SS": ["a\u0001", "a\u0001"]}} in the key answered One or more parameter values were invalid: Input collection ["a\u{1}", "a\u{1}"] contains duplicates., where this head answers ["a\u0001", "a\u0001"]. {"pk": {"SS": ["b", "a", "b"]}} in the key and {":a": {"SS": ["b", "a", "b"]}} in ExpressionAttributeValues both answered ... Input collection ["a", "b", "b"] contains duplicates., where this head lists ["b", "a", "b"].

#1368 builds these texts in the service's form for the other operations, in crates/core/src/types/attribute_value.rs. Whichever of #1368 and this PR merges second calls the other's helper and drops its own copy, so Scan gets the same form. The doc of SetFault::text and the description now say that this branch's text differs for such members.

# ahead of :a in 3); the set faults in sorted name order, where the
# service's two sends disagreed (the SS text, then the NS text) and the
# sorted order is pinned so that the answer does not depend on the backend.
("eavR-two-numbers", "table", '"FilterExpression": "a = :a", "ExpressionAttributeValues": '

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 exact body answered fred in 7 of 14 sends to the service and bob in the other 7. The row and the unit test the_order_r_number_check_visits_the_entries_in_the_hash_order should accept either answer. Row eavR-NSe-and-nest (line 566) expects the empty-set text, where the service answered the nesting text in 12 of 14 sends. Row eavR-NSbobdup-and-nest (line 630) expects the nesting text, where the service answered bob in 3 of 6 sends.

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.

Fixed. eavR-two-numbers and eavR-NSbobdup-and-nest accept either answer since the merge (5eb0132), and eavR-NSe-and-nest since cedc43f, in the file's ("either", ...) form. The unit test is now two_malformed_numbers_in_order_r_answer_one_of_the_two, and it accepts both texts. The rows are in tests/python/test_scan_request_rows.py after the split.

I sent the three bodies again on 2026-11-23 (14:12 UTC). The two numbers answered fred in 4 of 6 sends and bob in 2. Beside the nested value, the empty NS answered the empty-set text in 4 of 4, and {"NS": ["bob", "1", "1"]} answered bob in 4 of 4. With your counts, each row has both answers on record. The module doc of scan_request.rs, the doc of validate_sets and the description give the send counts.

'{"ComparisonOperator": "EQ", "AttributeValueList": [{"N": "1"}]}}, "Select": "BAD"', CONDOP),
("selR-arity-select-bad", "table", '"ScanFilter": {"a": {"ComparisonOperator": "EQ", '
'"AttributeValueList": []}}, "Select": "BAD"',
("either", "Invalid number of attribute values for comparison",

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 service answers One or more parameter values were invalid: Invalid number of argument(s) for the EQ ComparisonOperator here (4 sends). The row also accepts Invalid number of attribute values for comparison, which the service does not send. Expecting the service's text with an xfail matches how the ScanFilter number rows are marked.

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.

Fixed in cedc43f. selR-arity-select-bad now expects One or more parameter values were invalid: Invalid number of argument(s) for the EQ ComparisonOperator by equality, with an xfail for #838, as the file marks the two ScanFilter number rows for #507. I sent it again on 2026-11-23 (14:03 UTC, twice) and got that text. The row is in tests/python/test_scan_request_rows.py after the split.

The merge dropped EMPTY_AV from tests/test_scan_number_values.py.
tests/test_scan_checks_before_authorization.py imports it, so pytest
stopped at collection in every CI suite. The constant is back.

The key row {"M": {"k": {"N": "bob"}, "j": {}}} expected bob only when
EXTENDDB_TEST_BACKEND is mongodb. The member order depends on the build,
not on the backend. bson turns on serde_json's preserve_order, so a build
with the MongoDB crate names bob. CI's workspace build for PostgreSQL and
Cassandra is such a build. A build without it sorts the members and
names the empty value. The row now accepts either answer (#1013).
…sion

The merge of the base brought in a test of the Scan checks that run ahead
of the IAM decision. Two of its rows answered AccessDeniedException in CI:
an invalid Select, and an ExpressionAttributeValues entry with an unknown
type descriptor. This branch makes both checks in the handler, after the
IAM decision. The base made them before it.

The service answers both with its ValidationException to a principal that
may not Scan the table (measured 2026-11-19 with a role allowed only
DescribeTable). It makes some checks of the handler ahead of them. In both
orders these are a member of the wrong JSON type, the no-expression
checks, ConditionalOperator and the ScanFilter value count. In order U the
ScanFilter list values and the key's faults come first too.

So the handler's first checks move into checked_body. In order R it stops
after the Select enum. In order U it stops after the faulty entries and an
empty name. The handler calls it, and so does validate_before_authorization,
which the server now runs ahead of the IAM decision in place of
validate_scan_request_body. The server also passes the request text, so
these checks read the member order of the three maps from it, as the
handler does.
The doc of order R step 9 said the service makes the Select enum ahead
of the filter syntax (measured 2026-11-05). The comment beside the Select
check said the same. No row of this branch sends the two together. On
2026-11-19 the service answered the filter syntax, an undefined value and
an unused value ahead of an invalid Select, each request sent twice.
#1391 tracks that order. The code keeps its order, and the doc and the
comment now say so.

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

Items 1, 2, 3, 4, 6, 7, 8 and 10 from the earlier review are resolved at 1bdcf89. Items 5 and 9 remain open, as the PR body says. Each request was sent twice to the service and to SQLite builds of this head, with and without preserve_order. The 218 rows of the earlier wire file pass on this head, apart from two rows where the service itself gives two answers.

  • Both enum clauses sit in one message beside {":a": {}}, Limit: 1.5, Limit: 3000000000 and Segment: 0.5, and the six-fault body gives the service's six clauses in its order.
  • ScanFilter lists in order U match the service in every row tried. The seven type-fault bodies answer SerializationException.
  • The member-name bucket rule matches the service at 16 and 32 buckets for names picked from its hashing.
  • Member-order work is linear: 320,000 entries take 1.8 to 2.8 s, against 81 s at 2e3e499. With the sort in sorted_entries removed, two tests fail in the build with the MongoDB crate.
  • CI is green on 53 of 53 checks.

I will approve once the items below are done.

ExclusiveStartKey member order (fafd29b)

On builds with preserve_order (the MongoDB build, and the whole-workspace build CI runs), "ExclusiveStartKey": {"pk": {"M": {"k": {"N": "bob"}, "j": {}}}, "sk": {"S": "s"}} now answers The parameter cannot be converted to a numeric value: bob. The service answered The provided starting key is invalid: Supplied AttributeValue is empty, ... on 9 of 9 sends, and 2e3e499 gave the same answer. The wire row accepts either answer, so CI passes.

validate_before_authorization (316ea8e)

These checks now run ahead of the IAM decision, and no test covers them: a value of the wrong JSON type, ExpressionAttributeNames or ExpressionAttributeValues without an expression, ConditionalOperator, the ScanFilter value count, and in order U the list values and the key faults. With them reverted to after IAM, every test passes. A row for each in test_scan_checks_before_authorization.py would hold them.

Errors returned there also skip record_error_metrics and record_request_count. Six malformed Scans raise UserErrors and RequestCount by 6 on main and by 0 here. Query has the same gap (#1190).

crates/engine/src/scan.rs, crates/engine/src/query_key_values.rs

scan.rs grew from 591 lines after the split to 643, and query_key_values.rs is 725. Splitting by concern would bring both under 600.

Optional: checked_body runs twice

Every Scan that passes the early checks runs checked_body before IAM on a clone of the body, and again in the handler. A 7.6 MB body takes 2.22 s and about 600 MB here, against 1.33 s and 390 MB with the pre-IAM call removed, and 0.78 s and 340 MB on main. It stays linear, and it is under 0.25 s at 900 KB.

Optional: 32 nesting levels in ExpressionAttributeValues

The earlier review missed this. 8e4aa22 refuses a value nested 32 levels. The service accepts 32 and refuses 33, in 7 of 7 sends with two body shapes, and main accepts 32. Eight tests in the wire files fail against the service for this reason.

}
}

/// The `Select` field of a `Scan` body in order R, where the service checks

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.

SelectBody still says the service checks the Select enum ahead of the filter syntax. 1bdcf89 took that claim out of the other two places.

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.

Changed in fba4abf. The doc of SelectBody now says the service checks the enum after the no-expression check and the nesting check. It adds that the service makes the filter syntax, an undefined value and the unused values ahead of it (2026-11-19, #1391). The order R doc and the handler's comment say the same since 1bdcf89.

}
}

/// Measured 2026-11-05: in order U `ScanFilterBody::take` holds a `ScanFilter`

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 doc says take leaves a malformed number in the body in both orders. In order U it now takes the number out, as lines 329 to 353 assert.

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.

Changed in fba4abf. The doc now says that in order R the request-time checks pass a malformed number in a list and take leaves it in the body. In order U, take takes the number out and names it as the list's fault, as the assertions on [{"N": "bob"}, {}] below it do (2026-11-23).

…tion

The base brings its third round. The walk over one AttributeValue moves to
query_key_values/value_fault.rs. A float Limit, Segment or TotalSegments is
read from the digits the request wrote. The older validation path refuses an
empty or duplicate set. The Scan range rows beside a value move to a wire file
of their own.

- The base's set check and this branch's set check are one now. Fault::Set
  holds this branch's SetFault, which gives the text of either path. The
  number set duplicates come from the base's has_equal_numbers and its
  NUMBER_SET_DUPLICATES text. The base's deserializer_fault has no caller
  left and goes.
- Query keeps the base's older path: the numbers of every value, then the
  sets when an expression can read a value.
- Scan keeps this branch's order U. The request-time checks stop at the name
  keys. The handler checks the ExpressionAttributeValues entries after the
  expressions-only check and the key's faults. It reads the numbers and sets
  of each entry in one walk and visits the entries in the hash order.
  SCAN_VALUE_EXPRESSIONS has no caller left and goes.
- The base's set rows for Scan in unreadable_tests.rs now run through
  validate_before_authorization. Three answers change to the service's
  answers of 24 Nov at 05:41 UTC. Beside a number in :a, the set in :n is
  named, as the service named :n in both arrangements. With no expression,
  or with a ProjectionExpression alone, the answer is the expressions-only
  text.
…as the service does

The Scan checks refused an entry nested 32 L or M levels deep. The service
accepts 32 and refuses 33. The measurements of 24 Nov 2026 at 08:11 UTC
(us-east-1) sent each request twice to a table that does not exist. An L chain
and an M chain around {"N": "1"} that a FilterExpression reads answer
ResourceNotFoundException at 30, 31 and 32 levels. They answer the nesting
text at 33, 34 and 62. At 63 and 64 levels the service wraps the text as an
invalid value for key :d, as on 30 Oct. main accepts 32 levels too.

nested_too_deep reads the entry as JSON and refuses more than
MAX_ITEM_NESTING_DEPTH (32) levels. Order R makes the check at its step, after
the numbers and the sets. At 08:46 UTC, 33 levels answered the nesting text
ahead of the Select enum, the filter syntax, the no-expression check and the
key's number. The empty NS of another entry came ahead of the nesting text.

On the older validation path (order U) the service refuses such an entry as
a fault of the entry, in the invalid-value form. It visits the entries in the
hash order and finds the depth ahead of the faults inside the entry (08:46 and
08:47 UTC):

- Beside Limit 1.5, a 33-level :p answers ExpressionAttributeValues contains
  invalid value: Nesting Levels have exceeded supported limits: ... for key
  :p.
- {} inside 33 levels answers that text for its entry.
- The service names a 33-level :d ahead of {} in :e, and {} in :b ahead of :d.

ExpressionValuesBody now makes that check with the entry's other faults, and
the separate order U check in the handler goes. The nesting text moves from
core's partiql module to validation as NESTING_MESSAGE, so a build without the
partiql feature has it. partiql::params re-exports it.

With one limit for every Scan, the PartiQL SELECT no longer needs a Scan of its
own. A SELECT parameter may hold 32 levels, and the parameter check refuses 33
(measured 9 Nov). So ValuesDepth and handle_partiql_scan go. The SELECT calls
handle_scan with an empty request text.

The wire rows that pair a nested value with another fault send 33 levels now.
Each went to the service with 33 levels on 24 Nov at 08:46 or 08:59 UTC,
twice. B4-7 answers the nested entry's text for :d. A row with an empty leaf
inside 33 levels is new.
…the hash order

StartKeyBody::validate read the members of an M in an ExclusiveStartKey member
in the parsed map's order. A build without the MongoDB crate sorts them by
name. A build with it keeps the request's order, since bson turns on
serde_json's preserve_order. On the second kind of build, {"M": {"k": {"N":
"bob"}, "j": {}}} answered the number text for bob. The service answers the
prefixed empty value: 9 of 9 sends in the review, and again on 24 Nov 2026 at
08:11 UTC.

The service visits the members of such an M in the hash order it uses for the
key's own members. Measured on 24 Nov 2026 at 08:11 UTC (us-east-1, a table
that does not exist, each body twice). {"M": {"q": {"N": "bob"}, "b": {}}}
answers the number text, and {"M": {"b": {"N": "bob"}, "q": {}}} the prefixed
empty value. Request order would name bob for both. Sorted order would name
the empty value for the first body and bob for the second. With four buckets,
q is in bucket 1, b in 2, j in 2 and k in 3.

first_fault_in takes the member order as a function. first_fault keeps the
map's order, so an ExpressionAttributeValues entry answers as before (#1013).
StartKeyBody::validate passes hashed_members, which puts the members of an M
through fitted_member_order. Inside one bucket the parsed map's order stands
in for the request's.

The key row of the unit test and of the wire file expects the service's text
on every build. Two wire rows send the q and b bodies. The either form of
TestTwoOrders goes.
The doc of SelectBody still said the service checks the Select enum ahead of
the filter syntax. 1bdcf89 took that claim out of the order R doc and the
handler's comment. On 2026-11-19 the service answered the filter syntax, an
undefined value and an unused value ahead of an invalid Select (#1391). The
doc now says the same.

The doc of a_scan_filter_list_value_is_checked_at_its_step said that take
leaves a malformed number in a ScanFilter list in the body in both orders.
That holds in order R. In order U, take takes the number out and names it as
the list's fault, as the test asserts for [{"N": "bob"}, {}] (measured
2026-11-23).
scan.rs held 605 lines after the nesting change. CheckedBody and checked_body
move to scan/body_checks.rs as written. They are the checks a Scan body passes
ahead of the read, which the server also runs ahead of the IAM decision.
scan.rs keeps the handler at 496 lines. The struct's fields take pub(super) so
the handler can read them, and the imports of each file name what it uses.
crate::scan::checked_body stays the path the server's gate calls.
316ea8e moved the handler's checks ahead of the IAM decision. In order R they
run up to the Select enum, in order U up to the faulty
ExpressionAttributeValues entries. The review of 24 Nov lists the checks among
them that no test covered. They are a value of the wrong JSON type and the two
maps with no expression. Then come ConditionalOperator and the ScanFilter
value count. In order U, a list value and the key's faults. With those checks
after IAM again, every test passed.

test_scan_checks_before_authorization.py gets one row for each. The role
extenddb-test-665-e1, which may Scan no table, sent each body twice to a table
that does not exist. The sends were on 24 Nov 2026 at 08:28, 08:33 and 09:59
UTC. The rows of 19 Nov answer as they did then, and the valid body answers
AccessDeniedException.

Two rows answer SerializationException, so the table gains an error code
column. Two rows carry extenddb's text where the service's differs: the
ScanFilter value count (#838) and a Select of the wrong JSON type (#1012).
The row with ExpressionAttributeValues and no expression takes the older
path, where both give the suffixed text. On the newer path the service's text
has no suffix (#722).

Control: with the gate running the request checks alone, as before 316ea8e,
the eight new rows answer AccessDeniedException. Four of the earlier rows do
too.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

The branch merges the base again (fe0e3a0, fix/563-scan-range-constraints at 9963597) and adds five commits. The items of the review body:

  1. ExclusiveStartKey member order: fc6d8d9. The service visits the members of an M in a key value in the hash order it uses for the key's own members. Measured on 2026-11-24 at 08:11 UTC (us-east-1, a table that does not exist, each body twice): {"pk": {"M": {"q": {"N": "bob"}, "b": {}}}, "sk": {"S": "s"}} answers The parameter cannot be converted to a numeric value: bob, and {"pk": {"M": {"b": {"N": "bob"}, "q": {}}}, "sk": {"S": "s"}} the prefixed empty value text. Request order would name bob for both, sorted order the empty value for the first. With four buckets q is in bucket 1 and b in 2. {"M": {"k": {"N": "bob"}, "j": {}}} answers the prefixed empty value text, as on 2026-11-05 (j in bucket 2, k in 3). first_fault_in takes the member order as a function. StartKeyBody::validate passes hashed_members, which puts the members of an M through fitted_member_order. first_fault keeps the parsed map's order for ExpressionAttributeValues and the ScanFilter lists, so the two z rows answer as before (Two faults in one request map: ExtendDB can report another member than the service #1013). The key row expects the service's text on every build, two wire rows send the q and b bodies, and the either form of TestTwoOrders is gone. Control: with first_fault back in StartKeyBody::validate, the unit test fails on a build without the MongoDB crate, where the q and b body answers the empty value.

  2. validate_before_authorization: 00fec65 adds one row per check to tests/test_scan_checks_before_authorization.py. The rows are {"Limit": "5"}, {"Select": 5}, ExpressionAttributeNames with no expression, ExpressionAttributeValues with no expression, ConditionalOperator alone and a ScanFilter condition with no value. In order U they are [{}] in a list and {"pk": {}, "sk": {"S": "x"}}. The role extenddb-test-665-e1, which may Scan no table, sent each body twice to a table that does not exist. The sends were on 2026-11-24 at 08:28, 08:33 and 09:59 UTC. The two JSON type rows answer SerializationException (STRING_VALUE cannot be converted to Integer, NUMBER_VALUE cannot be converted to String), the others ValidationException with the check's text. The rows of 19 November answered as they did then, and the valid body AccessDeniedException. The table gains an error code column. Two rows carry extenddb's text where the service's differs: the value count (Scan: the Segment, ScanFilter value count and COUNT with AttributesToGet checks answer texts that differ from the service #838) and Select: 5 (A request member of the wrong JSON type gets serde_json's error text, where the service sends its own #1012). The ExpressionAttributeValues row takes the older path (Limit: 1.5), where both give the suffixed text. On the newer path the service's text has no suffix (Scan: ExpressionAttributeValues without an expression answers with a ": FilterExpression is null" suffix the service does not send #722). Control: with the gate running the request checks alone, as before 316ea8e, the eight rows answer AccessDeniedException on a SQLite server. So do Select, the unknown type descriptor and the two NS rows. "ConsistentRead": "yes" alone answered AccessDeniedException from that role (the service reads the string as a boolean, A boolean member given as a JSON string is read differently from the service #984), so it has no row.

    This PR does not close the metrics gap. A request refused in the authorization step records no UserErrors or RequestCount in /metrics #1190 reports it for every request refused in the authorization step, and fix(server): count a request refused in the authorization step in UserErrors and RequestCount #1427 fixes it at the handler's authorization error arm. The body says that a Scan refused ahead of the IAM decision records no UserErrors or RequestCount until fix(server): count a request refused in the authorization step in UserErrors and RequestCount #1427 merges, and that this PR merges after it.

  3. scan.rs, query_key_values.rs: 5257ed8 moves CheckedBody and checked_body to crates/engine/src/scan/body_checks.rs as written: scan.rs has 496 lines. The struct's fields take pub(super), and crate::scan::checked_body stays the path the server's gate calls. query_key_values.rs has 473 lines since the merge, where the base moved the value fault walk to query_key_values/value_fault.rs.

  4. checked_body runs twice: No change here. An authorized Query or Scan runs its request checks twice (#544, #562, #854) #1422 tracks it for fix(query): check Query values against the key schema and the number rules #544, fix(scan): check the numbers in ExpressionAttributeValues as the service does #562 and this PR.

  5. 32 nesting levels: e0f7d65. Measured on 2026-11-24 at 08:11 UTC, with an L chain and an M chain around {"N": "1"} read by the filter, on a table that does not exist. Both answer ResourceNotFoundException at 30, 31 and 32 levels and the nesting text at 33, 34 and 62. At 63 and 64 they answer the text wrapped as an invalid value for :d. nested_too_deep refuses more than MAX_ITEM_NESTING_DEPTH (32) levels. Order R makes the check at its step. Order U makes it a fault of the entry in the invalid-value form, found ahead of the faults inside it (08:46 and 08:47 UTC). Beside Limit: 1.5 a 33-level :p answers it for :p, and {} inside 33 levels answers it for its entry. A 33-level :d is named ahead of {} in :e, and {} in :b ahead of :d. The eight wire rows send 33 levels, each sent again on 2026-11-24 at 08:46 or 08:59 UTC. The module doc states the limit. The PartiQL SELECT of a whole table calls handle_scan with an empty request text, so ValuesDepth and handle_partiql_scan are gone. Control: with the 32-level bound back, three unit tests fail.

The two inline comments are fba4abf.

…tion

Brings in 0e0f078 and 35910e9 from fix/query-key-value-types and
its merge of main at 44cd436. It also brings in the merge commits
ad5f485 and bed665f of the two branches below this one.

Three conflicts, all in crates/engine/src/query_key_values/value_fault.rs,
in the doc comments of first_fault_in and set_fault and in the
signature line of first_fault_in. The merge keeps this branch's walk
(first_fault_in with a member order, SetFault) and its set_fault, which
builds the set texts of both paths. The merge drops the other branch's
deserializer-based set_fault. The doc comments gain the 2026-11-24 rows.

Carried in from the other branch: SS first in TYPE_DESCRIPTORS. The
walk then names a duplicate SS beside a second type descriptor ahead of
the numbers. The null member and null name handling in shape_fault_first
and the first pass of older_form_checks merged without conflict.
…tion

This merge adds main at b3c54f6, through the merges 6d74de7,
330d685 and 73a01ae on the three branches below this one.

One file conflicted: crates/engine/src/int32_member.rs, in newer_form.
The merge keeps this branch's newer_form, which puts the clause of an
empty list member first. It calls main's validation_errors_detected,
because the merge into fix/563-scan-range-constraints removed
validation_error_envelope.
…tion

This merge adds main at 018715e, through the merges 31c5f3d,
b33d458 and 627cb41 on the three branches below this one.

One file conflicted: crates/engine/src/scan.rs. Main's #765 passes no
expression parameters to the Scan values check. So a Scan whose values
the service reads gets the values message with no suffix. This branch
moved that check from handle_scan to checked_body in
crates/engine/src/scan/body_checks.rs. The merge keeps this branch's
scan.rs and puts #765's change in checked_body for the newer path.

On the older path, checked_body still names FilterExpression as null. The
service was asked on 2026-11-24 at 15:24 UTC, on a table that does not
exist. ExpressionAttributeValues with no expression got the text that has
no suffix. Beside Limit 1.5 it got the text with the suffix. Each
request went twice. #765's message gives the suffix for a value the
service cannot read as one type too. The merge does not change the rows
of tests/test_scan_checks_before_authorization.py and
query_key_values/unreadable_tests.rs that pin the older path's text.

@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 items from the earlier review are resolved at be52b90, with the metrics gap left to #1427. Each body was sent twice to the service in us-east-1 and to SQLite builds of this head with and without serde_json's preserve_order (the member order the MongoDB and workspace builds use).

  • An ExclusiveStartKey member holding {"M": {"k": {"N": "bob"}, "j": {}}} answers The provided starting key is invalid: Supplied AttributeValue is empty, ... on both builds, as on the service, and 11 of 12 related key rows match (q/b, b/q, a/b and b/a members, an M in an L and in an M, 4- and 3-member maps, an empty NS ahead of an empty value). Putting first_fault back fails the unit row on both builds and two wire rows.
  • 32 nesting levels in ExpressionAttributeValues are accepted and 33 refused with the nesting text, alone, unused, with no expression, beside Select: "BAD" and beside a key number, and in order U beside Limit: 1.5. PartiQL SELECT answers as before, and no statement can pass handle_scan an entry deeper than the parameter check allows. With the 32-level bound put back, 3 unit and 3 wire tests fail.
  • The 8 new rows for the checks ahead of IAM fail with the gate put back as it was. scan.rs is 496 lines and query_key_values.rs 497, by a pure move, and the SelectBody and holder_tests docs match the code. The merge leaves no : FilterExpression is null suffix in order R and keeps it beside Limit: 1.5, as on the service.
  • A Scan refused ahead of the IAM decision still records no metric (9 against 27 on the merge-base for the same 27 requests, at handler.rs:182). #1427 counts requests refused in the authorization step, and the body says this PR merges after it.
  • fmt, both clippy commands, the 1.91.1 workspace check and extenddb-core without default features are clean, 5270 workspace tests pass apart from the host's secmem test, the head wire files pass against the service apart from #838, and every CI workflow has a passing run at this head.

LeeroyHannigan added a commit that referenced this pull request Nov 25, 2026
…parison

The merge of #544's branch brought a second NUMBER_SET_DUPLICATES, in
validation::number, with the same text as the one that this branch adds
in types::attribute_value. It also brought has_equal_numbers, which
finds two members of a number set with one value, as the NS arm of
duplicates_as_sent does.

attribute_value.rs, BatchWriteItem and the PartiQL parameter tests now
use the constant of validation::number. Its doc comment gets the
2026-11-22 BatchWriteItem measurement of this branch. The NS arm of
duplicates_as_sent calls has_equal_numbers, which #850 and #854 call
too. This commit deletes the copy of the constant in attribute_value.rs,
its re-export from types, and the comparison in the NS arm. The answers
do not change.

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