Skip to content

fix(core): read a B value with its padding left out or cut short - #1313

Open
LeeroyHannigan wants to merge 16 commits into
fix/1189-base64-textsfrom
fix/1258-unpadded-base64
Open

LeeroyHannigan wants to merge 16 commits into
fix/1189-base64-textsfrom
fix/1258-unpadded-base64

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

ExtendDB now reads a B value or a BS member with no = padding or with part of it. It reads such a value in an item, a key and an expression attribute value, as DynamoDB does. The value must not carry bits outside a whole byte in its last character. The stored bytes are those of the padded value. A PartiQL parameter and a BatchWriteItem request still need the padding, as DynamoDB requires.

  • decode_base64 in crates/core/src/types/attribute_value.rs decodes with DecodePaddingMode::Indifferent.
  • The new decode_padded_base64 keeps the decoder that requires the padding. The PartiQL parameter checks in crates/core/src/partiql/params.rs call it.
  • Both use the one mapping of a refusal to its text that fix(core): send DynamoDB's text for a B value that does not decode #1260 adds.
  • The PartiQL echo in crates/engine/src/partiql/request_checks/echo.rs keeps its decoder, which requires the padding.
  • The new check_binaries in crates/core/src/types/attribute_value.rs walks one attribute value, with the values of its M and L. It gives the first refusal of a decoder for a B text or a string member of a BS. It leaves every other payload to the deserializer. ImportTable calls it with the standard decoder.
  • handle_batch_write_item in crates/engine/src/batch_write_item.rs runs padding_refusal before the deserializer. padding_refusal reads written_values with check_parameter_types of crates/core/src/partiql/params.rs, which decodes with decode_padded_base64. written_values are the attribute values of each PutRequest Item and each DeleteRequest Key, in the order the deserializer reads them. A B value or a BS member without its padding gets the SerializationException of that decoder. A fault of the wrong JSON type ahead of it, also inside its value, comes first, from the deserializer.
  • ImportTable keeps the decoder that requires the padding. read_dynamodb_json in crates/engine/src/import_export_io.rs runs check_binaries with the standard decoder on each value of the item. It refuses a DYNAMODB_JSON line with a B value or a BS member that this decoder does not read. Such a line gets Invalid DynamoDB item at line N, its answer before this PR.

check_parameter_types walks the same shapes as check_binaries and stops at a fault of another JSON type. ImportTable keeps check_binaries, because it needs the standard decoder. With #1355, decode_padded_base64 also reads values such as Y=Q=, which the import of DynamoDB refuses. A decoder parameter on check_types, the walk of check_parameter_types, would change a function that #1103 and #781 move to crates/core/src/serde_helpers.rs and that #1418 and #1437 call.

The base of this PR is #1260, which changes the same decoder.

Why

Fixes #1258

These are DynamoDB's answers, measured in us-east-1 on 21 November 2026 with signed requests. Each request went out twice and got the same answer both times. The PutItem rows used an on-demand table that the measurement created and then deleted, and a consistent GetItem read each stored value back. The ExecuteStatement and Query rows named a table that does not exist, so a value that DynamoDB reads gets ResourceNotFoundException. LENGTH(n) is SerializationException, Base64 encoded length is expected a multiple of 4 bytes but found: n.

Request DynamoDB ExtendDB on #1260 ExtendDB with this PR
PutItem {"B": "YQ"} stores YQ== LENGTH(2) stores YQ==
PutItem {"B": "YQ="} stores YQ== LENGTH(3) stores YQ==
PutItem {"B": "YWJjZA"} stores YWJjZA== LENGTH(6) stores YWJjZA==
PutItem {"B": "YWJjZA="} stores YWJjZA== LENGTH(7) stores YWJjZA==
PutItem {"B": "YWI"} stores YWI= LENGTH(3) stores YWI=
PutItem {"BS": ["YQ", "Yg"]} stores ["YQ==", "Yg=="] LENGTH(2) stores ["YQ==", "Yg=="]
PutItem {"B": "YR"} LENGTH(2) the same the same
PutItem {"B": "YWJ"} LENGTH(3) the same the same
Query, {"B": "YQ"} as an expression attribute value ResourceNotFoundException LENGTH(2) ResourceNotFoundException
ExecuteStatement, {"B": "YQ"} as a parameter LENGTH(2) the same the same
PutItem {"B": "Y=Q="} stores //Q= SerializationException with no message the same as on #1260

Every measured value gets DynamoDB's answer and stored bytes, except these:

DynamoDB's BatchWriteItem reads a B value or a BS member only with its padding. The BatchWriteItem requests went out on 22 November 2026, in the same way as the requests above. {"B": "YQ"} in a PutRequest item or a DeleteRequest key got LENGTH(2), and so did {"BS": ["YQ"]} in a PutRequest item. {"B": "YQ="} got LENGTH(3). BatchGetItem, TransactGetItems, GetItem, DeleteItem, TransactWriteItems and UpdateItem read the key or value YQ as the byte 0x61. This PR gives each of these answers.

The service reads only the items and keys of a BatchWriteItem, in request order. These requests went out on 2 December 2026, each twice, on a table that does not exist:

Request in RequestItems DynamoDB ExtendDB with this PR
{"PutRequest": {"Item": {"pk": {"S": "nb"}}, "B": "x"}} ResourceNotFoundException the same
{"PutRequest": {"Item": {"pk": {"S": "nb"}}}, "BS": ["x"]} ResourceNotFoundException the same
{"DeleteRequest": {"Key": {"pk": {"S": "nb"}}, "B": "x"}} ResourceNotFoundException the same
an item with "v": {"BS": [{"B": "YQ"}]} SerializationException Start of structure or map found where not expected ValidationException Supplied AttributeValue is empty, must contain exactly one of the supported datatypes (#1104)
an item with "B": "YQ" SerializationException Unexpected value type in payload SerializationException with the text of serde (#1012)
the item {"pk": {"S": 1}, "v": {"B": "YQ"}} SerializationException NUMBER_VALUE cannot be converted to String SerializationException Start of structure or map found where not expected: S value must be a string (#1012)
the item {"a": {"B": "YQ"}, "pk": {"S": 1}} LENGTH(2) the same

PutItem answers the three items of the wrong JSON type as BatchWriteItem does, on DynamoDB and on ExtendDB. The item {"v": {"B": "YQ"}, "pk": {"S": 1}} gets LENGTH(2) from DynamoDB. A build with the MongoDB crate keeps the order of a JSON map, so there the walk reaches v first and gives LENGTH(2) too. No test runs that order. A build without the MongoDB crate reads the members in name order and reports the S fault.

The service also reads inside a value in request order. These requests went out on 3 December 2026 in the same way. Unless a row gives the item, the item is {"pk": {"S": "k"}, "v": VALUE}.

VALUE or item DynamoDB ExtendDB with this PR
{"M": {"a": {"S": 1}, "b": {"B": "YQ"}}}, and the two values in an L SerializationException NUMBER_VALUE cannot be converted to String SerializationException Start of structure or map found where not expected: S value must be a string (#1012)
{"M": {"a": {"B": "YQ"}, "b": {"S": 1}}}, and the two values in an L LENGTH(2) the same
{"BS": [{"B": "YQ"}, "YQ"]} SerializationException Start of structure or map found where not expected ValidationException Supplied AttributeValue is empty, must contain exactly one of the supported datatypes (#1104)
{"BS": [1, "YQ"]} SerializationException only base-64-encoded strings are convertible to bytes the same ValidationException (#1104)
{"BS": [null, "YQ"]} and {"BS": ["YQ", 1]} LENGTH(2) the same
the item {"a": {"X": "y"}, "v": {"B": "YQ"}} LENGTH(2) the same
{"B": "YQ", "S": "x"}, {"S": "x", "B": "YQ"} and {"M": {"a": {"B": "YQ", "NULL": true}}} LENGTH(2) the same
an item with "u": {"S": null} or "u": {"L": [null]} ahead of "v": {"B": "YQ"} LENGTH(2) the same
an item with "u": {"SS": [1]} ahead of "v": {"B": "YQ"} SerializationException NUMBER_VALUE cannot be converted to String ValidationException One or more parameter values were invalid: An string set may not have a null string as a member (#1104)

These are the rules of check_parameter_types, the first pass of the PartiQL parameter checks (measured on 6 November 2026). It reads the members in order. It passes over a member that the model does not name, a null payload, and a null member of a BS, an M or an L. It stops at a member of the wrong JSON type, also inside a set. On 3aadd30 the check gave LENGTH(2) to the first, third and fourth rows and to the SS item. The null items got the answer of the deserializer.

DynamoDB's ImportTable reads a B value only in the canonical padded form. Two imports of the same 18 S3 objects, one item each, on 22 November 2026, gave the same answers. Each import took the item with {"B": "YQ=="}. It refused the 17 others, among them {"B": "YQ"}, {"B": "YQ="} and {"BS": ["YQ", "YQ=="]}. Each import ended FAILED with ItemValidationError. Without the import check, this PR would make ExtendDB import YQ and YQ=. On a SQLite build of e030be2, a file with the YQ line got ValidationException and Invalid DynamoDB item at line 1. ExtendDB imported a file with the YQ== line.

Overlap with #1418 and #1437

#1418 adds check_base64 in crates/core/src/types/attribute_value.rs, and #1437, whose base is #1418's branch, keeps it. check_base64 is a walk that decodes each B and BS text of a value at any depth. check_binaries in this PR does the same walk, with the decoder as a parameter. Whichever of the two stacks merges second reuses the walk of the other. This PR came first: it opened on 21 November, and #1418 on 24 November.

Conflicts

git merge-tree shows no conflict with origin/main. #781 conflicts with main and with #1260 in params.rs, and #1103 with #1260. The lines of this PR that call decode_padded_base64 are inside those hunks. A resolution keeps them.

The v1.2.0 entry of this PR sits at the top of "Behavior Changes by Release" in docs/manuals/07-upgrade-manual.md. Only the two entries of main that #1446 and #1531 add are above it. Other open PRs add their entries at the top too, so a merge with any of them conflicts there. #1110, #1114 and #1126 add theirs below the entry of #1260, and conflict there. Whichever PR merges second keeps both entries.

This PR adds one conflict in the code:

Not in this PR

Testing done

All runs below are on e030be2, before the merges of #1260's new heads, unless a line names another tree. "Changes since the last review" gives the runs on the commits since the last review.

  • cargo +1.97.0 test -p extenddb-core --no-fail-fast: 1147 unit tests passed and 1 is marked ignored. The integration and doc tests passed. cargo +1.97.0 test -p extenddb-engine --lib: 930 passed. The first run of the crate had one failure, the backup timing test a_stopped_heartbeat_timer_stops_the_restore_before_its_next_write, which this PR does not change. It passed in the second run.
  • cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warnings, the same for extenddb-engine with --features extenddb-engine/backup-test-hooks, the same for extenddb-core with --no-default-features, cargo +1.91.1 check -p extenddb-core -p extenddb-engine --all-targets and cargo +1.97.0 fmt --all -- --check are clean.
  • The base of this PR did not have main's WebAssembly workflow then. On a merge of e030be2 with main, its clippy step, cargo +1.97.0 clippy --locked -p extenddb-wasm-adapter --lib --release --target wasm32-unknown-unknown -- -D warnings, is clean.
  • With the two decoders swapped, a_value_that_is_not_base64_gets_the_service_text fails at YQ and a_value_of_the_wrong_json_type_is_found_ahead_of_any_other_problem fails at AQ=.
  • The new engine test batch_write_item_alone_reads_a_binary_only_with_its_padding sends 12 of the measured requests through the engine. Without the BatchWriteItem check, its 5 BatchWriteItem rows with a value that has no full padding fail.
  • The new test import_reads_a_binary_only_in_the_canonical_form passes. Without the ImportTable check, it fails at YQ, YQ= and the two nested rows.
  • The BatchWriteItem test builds its own engine context on a bootstrapped SQLite engine, in 35 lines. tests/private_modes.rs has the same context, but that test binary holds one test by design, because it sets the umask to 0. The other engine test contexts run no migrations, so CreateTable fails on them.
  • Against ExtendDB on SQLite: tests/test_binary_base64.py and tests/test_attribute_value_validation.py passed 217 tests. The six PartiQL wire files (test_partiql_batch.py, test_partiql_grammar.py, test_partiql_key_conditions.py, test_partiql_requests.py, test_partiql_transaction.py, test_partiql_write.py) passed 1976, with 3 skipped and 2 marked xfail. tests/test_query_value_shapes.py and tests/test_query_leading_keys_values.py passed 115.
  • Against fix(core): send DynamoDB's text for a B value that does not decode #1260's head, 5 rows of tests/test_binary_base64.py fail: the 4 PutItem rows and the Query row whose values do not have their full padding.
  • The 22 measured rows of ExtendDB refuses a B value whose base64 has no padding or a padding character inside, which DynamoDB reads #1258 went to the server of e030be2, each twice, and GetItem read back each value written. 19 rows get DynamoDB's answer and stored bytes. The other 3 are Y=Q= and =YQ= (A B value with "=" inside, such as Y=Q=, gets SerializationException, where DynamoDB stores bytes for it #1307) and {"BS": ["Yg==", "Yg"]} (A BS with two spellings of one value gets another duplicates text than DynamoDB's #1312).
  • The 13 measured requests of the BatchWriteItem paragraph went to the same server, each twice. 12 get DynamoDB's answer. The other one is Y=Q= in a PutRequest item, which DynamoDB stores (A B value with "=" inside, such as Y=Q=, gets SerializationException, where DynamoDB stores bytes for it #1307).
  • 6,057 generated DYNAMODB_JSON lines got the same answer from the import on main and on fix(core): read a B value with "=" or another character inside #1355's branch with this PR's ImportTable check merged. Without the check, 203 of them got another answer.

The line counts count the Python files and the Rust lines of an inline test module as tests. At f7f1849 against #1260's head 5885e20: production +135 -10, tests +311 -10, and 8 lines of the upgrade manual. The commit 6b21d47 is production +89 -37 and tests +64 -12, and 7dfea6a is production +19 -23 and tests +31 -11.

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

In an item, a key and an expression attribute value, ExtendDB now reads a B value or a BS member without its full = padding. Before, it refused such a value with a SerializationException. A PartiQL parameter and ImportTable keep their answers. BatchWriteItem keeps its refusal of such a value. It now gives that refusal also beside a second type descriptor, and after an unknown type descriptor or a null. 1.1.0 refused such a request with the text of the other fault. The stored data does not change. The v1.2.0 entry of docs/manuals/07-upgrade-manual.md gives these changes.


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.

ExtendDB decoded a B value or a BS member with a decoder that requires
the "=" padding. It refused YQ, YQ=, YWJjZA and YWJjZA= with a
SerializationException. DynamoDB reads them, in an item and in an
expression attribute value, and stores the bytes of the padded value.
It refuses them in a PartiQL parameter, with the text of their length.
DynamoDB refuses a value whose last character carries bits outside a
whole byte, such as YR or YWJ, in both places. Measured in us-east-1 on
21 Nov 2026.

decode_base64 now decodes with a padding mode that accepts the padding
left out or cut short, and keeps the texts of a refusal.
decode_padded_base64 keeps the decoder that requires the padding, and
the checks of the PartiQL parameters call it. Both share one mapping of
a refusal to its text. A value with "=" inside, such as Y=Q=, is #1307.

Fixes #1258.
ImportTable reads each line of a DYNAMODB_JSON file with the attribute
value deserializer of the requests. The previous commit makes that
deserializer read a B value with its padding left out or cut short. So
ImportTable read the B value YQ as the byte 0x61, where it refused the
line before.

DynamoDB's ImportTable refuses those values. Two imports of the same 18
files on 2026-11-22, one item per file, gave the same answers. Each
import took the item whose B value is YQ==. It refused the items with
these B values: YQ, YQ=, Y=Q=, =YQ=, Y-Q=, =A==, YWJjY=Q=, Y=Q, =Y==,
=YQA, "Y Q=", Y, == and "Y=Q=\n". It also refused the BS values
[Y=Q=, //Q=], [Y=Q=, =YQ=] and [YQ, YQ==]. Each import ended FAILED
with ItemValidationError, ImportedItemCount 1 and ErrorCount 17.

read_dynamodb_json now refuses a line with a B value or a BS member that
is not canonical padded base64. This applies at any depth inside M and L
values. The answer is the one the line had before the previous commit:
Invalid DynamoDB item at line N. The imports measured values at the top
level of the item only. Requests keep the new reading.

Refs #1258.
An earlier commit of this branch makes the attribute value deserializer
read a B value with no padding or with part of its padding. BatchWriteItem
reads its request with that deserializer. So it accepted the B value YQ
in a PutRequest item and in a DeleteRequest key, where it refused the
value before.

DynamoDB's BatchWriteItem reads a B value or a BS member only with its
padding. Measured in us-east-1 on 2026-11-22, each request twice. The B
value YQ in a PutRequest item gave a SerializationException. Its text
was "Base64 encoded length is expected a multiple of 4 bytes but found:
2". YQ= gave the same text with 3, and the BS value [YQ] gave it with 2.
The DeleteRequest key YQ and the PutRequest key Yg gave it with 2 too.
BatchGetItem, TransactGetItems, GetItem, DeleteItem, TransactWriteItems
and UpdateItem read the key or value YQ as the byte 0x61.

handle_batch_write_item now checks the raw RequestItems with
decode_padded_base64 ahead of the deserializer. That is the decoder of
the PartiQL parameters. The answer is a SerializationException with the
text of that decoder. The walk covers the RequestItems member only, and
the deserializer reads the rest of the body as before. The walk over a
body's B texts is the one the previous commit added for ImportTable. It
moves to extenddb_core::types as check_binaries and takes the decoder as
a parameter. ImportTable keeps the standard decoder. The requests of the
other operations keep the deserializer's reading.

Refs #1258.
The one conflict is the pub use line of crates/core/src/types/mod.rs. The
merge keeps the exports of both sides.
The base merges #544's branch and adds the rows "//==" and "++==" to the
decoder tests. Three conflicts come from these rows and their dates:

- The row count of a_value_that_is_not_base64_gets_the_service_text in
  crates/core/src/types/attribute_value.rs. This branch adds 6 rows and
  the base adds 2, so the table now has 56. Its doc comment gives the
  dates of both sides.
- The comment over the B and BS parameter rows in
  crates/core/src/partiql/params.rs. The merge keeps the base's three
  dates and this branch's sentence about the padding.
- The docstring of tests/test_binary_base64.py. The merge keeps this
  branch's sentence about the padding and gives the three dates.
The doc comment of import_reads_a_binary_only_in_the_canonical_form says
that the rows with YQ inside an M and an L were not measured. It now also
gives the reason for their expected answer. The import reads a B value
with the standard decoder at any depth, so these rows get the answer of
the top-level YQ row.
The base merges main at 14ade59. That brings #544 as a squash and
ten other commits: #1280, #1009, #596, #1173, #398, #428, #567, #584,
#588 and #864. The merge has no conflict. No file has changes on both
sides.

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

I think the BatchWriteItem check reads more than the attribute values. check_binaries(&body["RequestItems"], decode_padded_base64) decodes any string under a member named B, and any string in an array under BS, anywhere in RequestItems. WriteRequest, PutRequest and DeleteRequest skip members they do not model, so the check now decodes members the deserializer never reads. I sent {"RequestItems": {"<table>": [{"PutRequest": {"Item": {"pk": {"S": "nb"}}, "B": "x"}}]}} to SQLite builds. main at aff626e and #1260 at 639ff59 answer 200 and write the item. 05c9baf, and 05c9baf merged with main, answer SerializationException Buffer is too short for base64 encoding. "BS": ["x"] beside PutRequest and "B": "x" beside Key in a DeleteRequest get the same answer, and "B": "YQ" beside Item gets Base64 encoded length is expected a multiple of 4 bytes but found: 2. PutItem with an unknown top level "B": "x" is served on every build. The doc comment says "Matching member names is safe: a value that deserializes holds attribute values there, and any other value is refused", which does not hold for these members. Has anyone checked what DynamoDB answers for an unknown member in a WriteRequest? If it ignores it, as main does, this is a regression. Could the check walk only PutRequest.Item and DeleteRequest.Key of each list, value by value?

The same walk changes the answer for three malformed items, where main gives the deserializer's answer:

  1. {"BS": [{"B": "YQ"}]}: main and #1260 answer ValidationException Supplied AttributeValue is empty, must contain exactly one of the supported datatypes, as PutItem does on this head. BatchWriteItem on this head answers SerializationException with the length text. The description says the walk reads every B text "as the deserializer does", but binary_set does not decode a B inside a BS member.
  2. An item attribute "B": "YQ", a string where a value belongs: main answers Start of structure or map found where not expected: invalid type: string "YQ", ..., as PutItem does. BatchWriteItem on this head answers the length text.
  3. {"pk": {"S": 1}, "v": {"B": "YQ"}}: main and #1260 name the first fault (S value must be a string), and this head names the later B. Was a request with an earlier fault of the wrong JSON type among the BatchWriteItem measurements? If not, could one be measured, since the description says the service refuses the padding "ahead of the rest of the request"?

Walking only the attribute values, and decoding only the string members of a BS, would leave the first two to the deserializer.

The wasm check on this head fails with E0308 at crates/core/src/metrics/collector.rs:60, the error main had at 14ade59 before #1482. 05c9baf merges with current main (aff626e) with no conflict. On that merge a workspace cargo check of all targets, clippy on core and engine, fmt, and the core (1243), engine (980) and wasm adapter tests pass, and tests/test_binary_base64.py with five other wire files passes on SQLite. Could you merge main so CI runs on it?

I will approve once the BatchWriteItem check reads only the item and key values (or DynamoDB is shown to refuse an unknown B member) and CI is green on a branch with current main.

The base merges main at c8e66fb, which brings #1465, #1515 and #1411.
#1411 adds a v1.2.0 entry to docs/manuals/07-upgrade-manual.md. The
merge has no conflict, and no file has changes on both sides.
Add a v1.2.0 entry at the top of "Behavior Changes by Release" in
docs/manuals/07-upgrade-manual.md, above the entries of main and #1260.
It gives the values that 1.1.0 refused and this branch reads, the bytes
they store, and the requests that still need the padding.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings main at c8e66fb through #1260, with #1465, #1515 and
#1411, and adds the v1.2.0 entry of #1313 to
docs/manuals/07-upgrade-manual.md. The merge has no conflict, and no
file has changes on both sides.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
Add a v1.2.0 entry at the top of "Behavior Changes by Release" in
docs/manuals/07-upgrade-manual.md, above the entry of #1313. It gives
the values with "=" or another character inside that 1.1.0 refused and
this branch stores. It also gives the texts of the values that DynamoDB
refuses, the BS duplicates text and the echo of a long PartiQL list.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings main at c8e66fb through #1260, with #1465, #1515 and
#1411, and adds the v1.2.0 entry of #1313 to
docs/manuals/07-upgrade-manual.md. Git merged the manual with no
conflict. The order of the v1.2.0 entries is #1313, #1411, #606, #1260,
then the entry of this branch. No other file has changes on both sides.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings main at c8e66fb through #1260, with #1465, #1515 and
#1411, and adds the v1.2.0 entries of #1313 and #1355 to
docs/manuals/07-upgrade-manual.md. The merge has no conflict, and no
file has changes on both sides.
@navareamol

Copy link
Copy Markdown
Collaborator

I think a fault inside one value still loses to a B without padding in the same value. The doc comment of padding_refusal says "Inside one value, the refusal is reported first", and the code does that for nested values. The rows below ran on 6512dcd with the SQLite build. BatchWriteItem answers the length text of YQ. Where I ran PutItem or main, that answer is named.

  1. {"M": {"a": {"S": 1}, "b": {"B": "YQ"}}} and {"L": [{"S": 1}, {"B": "YQ"}]}: PutItem and main answer S value must be a string.
  2. {"BS": [{"B": "YQ"}, "YQ"]}, {"BS": [1, "YQ"]} and {"BS": [null, "YQ"]}: PutItem (first one) and main answer Supplied AttributeValue is empty, must contain exactly one of the supported datatypes.
  3. {"a": {"X": "y"}, "v": {"B": "YQ"}}, an unknown type descriptor ahead of the B: PutItem and main answer unknown AttributeValue type descriptor. shape_fault skips that text on purpose, as the Query checks do, so I wonder if it is right here.
  4. {"B": "YQ", "S": "x"} and {"M": {"a": {"B": "YQ", "NULL": true}}}, a value with two descriptors: main answers Supplied AttributeValue has more than one datatypes set.

Your live measurements cover the attributes of one item, S 1 then B and B then S 1, and show the service reading the item in request order. I think it reads inside a value in order too, which would make these four a change from main with no measurement behind it. Have you measured one of them on the service, for example the first row on a table that does not exist? If the service reports the first fault inside a value, check_binaries could take the same ahead-of check inside M, L and BS, or the check could leave a value to the deserializer when shape_fault finds a fault in it.

The three other points are resolved on my side.

On the head I ran: core, engine and wasm adapter unit tests, clippy and fmt, the six wire files with your test file and my attack file on SQLite (1224 passed), 827 probes with no 5xx and no panic, requests of 25 items of 380 KB and a BS of 100000 members (under one second, same as main), and the PartiQL parameters, ExecuteTransaction and ImportTable paths. I found nothing else.

I will approve once the nested order is measured or settled, and the pending checks finish green.

Inside one value, the padding check of BatchWriteItem reported a B
without its padding ahead of an earlier fault of the wrong JSON type.
For example, {"S": 1} ahead of {"B": "YQ"} in an M or an L got the
length text of YQ. So did an object or a number ahead of "YQ" in a BS.

DynamoDB reads inside a value in request order and reports the first
fault (measured 2026-12-03, each body twice, on a table that does not
exist):

- {"M": {"a": {"S": 1}, "b": {"B": "YQ"}}} and the same two values in
  an L get "NUMBER_VALUE cannot be converted to String". With the B
  first, both get the length text of YQ.
- {"BS": [{"B": "YQ"}, "YQ"]} gets "Start of structure or map found
  where not expected". {"BS": [1, "YQ"]} gets "only base-64-encoded
  strings are convertible to bytes".
- An SS member of another JSON type in a value ahead of the B gets
  "NUMBER_VALUE cannot be converted to String".
- The read does not stop at an unknown type descriptor or a second
  type descriptor ahead of the B. It does not stop at a null payload or
  a null member of a BS or an L either. The B gets the length text of
  YQ.

These are the rules of check_parameter_types, the first pass of the
PartiQL parameter checks (measured 2026-11-06). padding_refusal now
reads each value of written_values with it. It keeps a base64 refusal
and leaves every other fault to the deserializer. This replaces
check_binaries and shape_fault in BatchWriteItem, and shape_fault is
private again, as on main.

The 15 measured rows join
batch_write_item_checks_the_padding_of_the_items_and_keys_alone. The
five rows with a fault ahead of the B expect the answer of a PutItem of
the same item, as m4 to m6 do. The texts of the deserializer differ
from the texts of DynamoDB there (#1104, #1012).
…anges

The v1.2.0 entry of this PR now says which BatchWriteItem answers change
from 1.1.0. A B without its padding gets the length text beside a second
type descriptor, and after an unknown type descriptor or a null. 1.1.0
refused such a request for the other value. A fault of the wrong JSON
type ahead of the B keeps its 1.1.0 answer. DynamoDB gives these answers
(measured 2026-12-03, each body twice, on a table that does not exist).
… the other fault

The v1.2.0 entry said that 1.1.0 refused such a request for the other
value. Beside a second type descriptor, the other fault is in the same
value. So the entry now says that 1.1.0 answered with the text of the
other fault. The PR body gives the same wording.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings a new BatchWriteItem check. It reads a fault ahead of a
B in request order, also inside a value. The base also adds a sentence
to its v1.2.0 entry. The merge has no conflict. Git merged two files
with changes on both sides at other lines:

- padding_tests.rs: the new rows and comment of the base, and row w3 of
  this branch.
- the upgrade manual: the new sentence in the entry of #1313, and the
  entry of this branch above it.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings a new BatchWriteItem check. It reads a fault ahead of a
B in request order, also inside a value. The base also adds a sentence
to its v1.2.0 entry. The merge has no conflict. Git merged the upgrade
manual, where both sides changed other lines. The base adds the new
sentence to the entry of #1313. This branch has its entry below the
entry of #1260. No other file has changes on both sides.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings the BatchWriteItem check of #1313 that reads a fault
ahead of a B in request order, also inside a value. It also brings the
new sentence of the v1.2.0 entry of #1313 and the new Python test of
#1355.

One file conflicted: crates/engine/src/batch_write_item.rs, in the
import list. The base drops AttributeValue, check_binaries and
decode_padded_base64 and adds is_base64_refusal. The resolution also
keeps first_duplicates_as_sent and is_listed_duplicates of this branch.
Git merged padding_tests.rs, query_key_values.rs and the upgrade manual
at other lines.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

Measured on 3 December 2026 with BatchWriteItem, each body twice, on a table that does not exist. In rows 1, 2 and 4, the value sat in an item after "pk": {"S": "k"}. LEN2 is Base64 encoded length is expected a multiple of 4 bytes but found: 2. The service reads inside a value in request order, and it reads past some faults:

  1. {"M": {"a": {"S": 1}, "b": {"B": "YQ"}}} and {"L": [{"S": 1}, {"B": "YQ"}]} get NUMBER_VALUE cannot be converted to String. With the B first, both get LEN2.
  2. {"BS": [{"B": "YQ"}, "YQ"]} gets Start of structure or map found where not expected. {"BS": [1, "YQ"]} gets only base-64-encoded strings are convertible to bytes. {"BS": [null, "YQ"]} and {"BS": ["YQ", 1]} get LEN2.
  3. {"a": {"X": "y"}, "v": {"B": "YQ"}} gets LEN2, so shape_fault was right to skip the unknown type descriptor.
  4. {"B": "YQ", "S": "x"}, {"S": "x", "B": "YQ"} and {"M": {"a": {"B": "YQ", "NULL": true}}} get LEN2.

Two more items: {"S": null} or {"L": [null]} ahead of the B gets LEN2, and {"SS": [1]} ahead of it gets NUMBER_VALUE cannot be converted to String.

These are the rules of check_parameter_types, the first pass of the PartiQL parameter checks. 7dfea6a makes padding_refusal read each value of written_values with it and keep only a base64 refusal. Any other first fault goes to the deserializer. So the S rows of 1, the object and number rows of 2 and the SS item get the answer of main and PutItem again. The texts differ from those of the service (#1012, #1104). The null row of 2, row 3, row 4 and the two null items get LEN2, as on the service. Main gives another answer there, and 6825c8e adds that to the v1.2.0 entry. 835b5ae says in that entry that 1.1.0 answered with the text of the other fault. shape_fault is private again, and the doc comment of padding_refusal no longer says the refusal comes first inside a value.

batch_write_item_checks_the_padding_of_the_items_and_keys_alone has these 15 requests as n1 to n15. With the production files of 3aadd30, n1, n2, n5, n6, n13, n14 and n15 fail.

The new head is 835b5ae.

@navareamol

Copy link
Copy Markdown
Collaborator

The mongodb-rust job failed on 835b5ae. The failing test is the_encryption_key_commands_run_on_a_mongodb_catalog, which panicked at crates/storage/src/key_conformance.rs:95 on .expect("the row"). This PR changes no storage file. #1355 holds the same commits and its mongodb-rust job passed, so I think this is a flake. Could you rerun it? I have not run it on main. Three checks are still pending: cassandra-integration, integration and mongodb-integration.

The nested order is resolved on my side. padding_refusal now reads each value with check_parameter_types and keeps only a base64 refusal, so the first fault inside a value goes to the deserializer unless it is a base64 text, and the doc comment no longer says the refusal comes first. I read the old padding_refusal against n1 to n15. It gives the same seven failures you list: n1, n2, n5, n6, n13, n14 and n15. I did not run the old files. run-tests passes on this head with n1 to n15. Your measurements on the service for these rows are the author's, and I did not repeat them.

The entry in docs/manuals/07-upgrade-manual.md says 1.1.0 refused such a request with the text of the other fault. I built tag v1.1.0 and sent the rows to BatchWriteItem on an existing table. n10, n11 and n12 answer more than one datatypes set. n9 answers unknown AttributeValue type descriptor: X, also on a table that does not exist. n13 answers S value must be a string, n15 answers the invalid type: null text and n7 answers Supplied AttributeValue is empty. n3, n4 and n8 answer invalid base64: Invalid padding on 1.1.0, and the entry does not claim otherwise. The sentence matches.

One question that I will not hold the approval on. check_parameter_types skips a null member of an M as it skips one of an L. You measured {"L": [null]} ahead of the B (n15). Has {"M": {"a": null, "b": {"B": "YQ"}}} been measured on the service? If it answers the length text, nothing changes. If it answers the fault of the null, padding_refusal would need to stop at a null member of an M.

Main has moved since this branch was cut. A merge of current main (c057660) conflicts in docs/manuals/07-upgrade-manual.md, because #1446 added an entry just above the #1411 entry. This shows when the stack lands.

I will approve once mongodb-rust is green on a rerun and the three pending checks finish green.

The base merges main at b6c8595, which brings #1446, #1531 and #1466.
The base also adds 15 rows to tests/test_binary_base64.py.

One file conflicted: docs/manuals/07-upgrade-manual.md. #1446 and #1531
add two v1.2.0 entries at the top of "Behavior Changes by Release",
where this branch adds its entry. The merge keeps the three entries:
the two entries of main first, then the entry of this branch, above
the entry of #1411. Git merged tests/test_binary_base64.py at other
lines. It holds the new rows of the base and the rows of this branch.
No other file has changes on both sides.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings main at b6c8595 through #1260, with #1446, #1531 and
#1466. It also brings the 15 new rows of #1260 in
tests/test_binary_base64.py.

One file conflicted: docs/manuals/07-upgrade-manual.md. #1446 and #1531
add two v1.2.0 entries at the top of "Behavior Changes by Release",
where this branch adds its entry. The merge keeps the two entries of
main first, then the entry of this branch, then the entry of #1313.
Git merged tests/test_binary_base64.py at other lines. No other file
has changes on both sides.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings main at b6c8595 through #1260, with #1446, #1531 and
#1466, and the 15 new rows of #1260 in tests/test_binary_base64.py.
The merge has no conflict. Git merged the upgrade manual, where both
sides changed other lines. The base adds the two entries of main above
the entry of #1313, and this branch has its entry below the entry of
#1260. No other file has changes on both sides.
LeeroyHannigan added a commit that referenced this pull request Dec 3, 2026
The base brings main at b6c8595 through #1260 and #1313, with #1446,
#1531 and #1466. It also brings the 15 new rows of #1260 in
tests/test_binary_base64.py.

One file conflicted: docs/manuals/07-upgrade-manual.md. #1446 and #1531
add two v1.2.0 entries at the top of "Behavior Changes by Release",
where this branch adds its entry. The merge keeps the two entries of
main first, then the entry of this branch, then the entry of #1355.
No other file has changes on both sides.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol The mongodb-rust rerun passed: run 47064403631, attempt 2. All 72 checks on 835b5ae passed, and that includes the three that were pending.

f7f1849 merges the new head of #1260, which merges main at b6c8595. The upgrade manual conflicted, as you said. The merge keeps the two entries of main first, then the entry of this PR, above the entry of #1411. The checks run again on this head.

No measurement on the service covers {"M": {"a": null, "b": {"B": "YQ"}}}. The closest measured rows are n7, {"BS": [null, "YQ"]}, and n15, {"L": [null]} ahead of the B. Both got the length text on 3 December. padding_refusal does not change.

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

Nothing in the code of this PR changed since 835b5ae. Between that head and f7f1849 the only file under crates or tests that differs is tests/test_binary_base64.py, which gains the 15 rows of #1260. The rest of the diff is main, merged through #1260.

I ran the engine tests with the filter padding on this head and they pass, including rows n1 to n15. With the production files batch_write_item.rs and query_key_values.rs put back to 3aadd30, the same test fails on n1, n2, n5, n6, n13, n14 and n15, which is your list of seven. On a SQLite build of this head, 1169 wire tests passed, among them test_binary_base64.py with the new rows. Your service answers for these rows are your measurements and I did not repeat them.

The mongodb-rust failure is settled. Run 47064403631 attempt 2 on 835b5ae shows mongodb-rust as success. The upgrade manual at this head lists the Cassandra entry, the MongoDB entry, this PR's entry and the DeleteTable entry in that order, with no conflict markers.

The question about a null member of an M stays open. You wrote that no measurement covers it and that n7 and n15 got the length text, so I do not hold the approval on it.

Main moved again to 5826e1b (#1087), and docs/manuals/07-upgrade-manual.md conflicts with it at the top of the release list. It does not hold this PR, and the stack can fix it when it lands.

All 70 checks pass on f7f1849, so I approve.

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