Repository navigation
fix(core): read a B value with "=" or another character inside - #1355
LeeroyHannigan wants to merge 16 commits into
Conversation
The test module of attribute_value.rs moves to attribute_value/tests.rs as it is, four spaces less indented, under the file header. No code or test changes.
ExtendDB refused a B value or a BS member with "=" or another byte
outside the base64 alphabet ahead of its padding, such as Y=Q= or =YQ=,
with a SerializationException and no message. It also gave no message to
values such as A=B=, Y=R=, =Y== and Y,==. It gave "Invalid last non-pad
Base64 character dectected" to a value of 8 bytes or more that ends in
five or more "=", such as YQ======, where DynamoDB gives no message.
DynamoDB reads a value a second time when the standard decoder refuses
it. A length that is not a multiple of 4 bytes gets the text that names
the length. Up to two "=" at the end are the padding. A value without
padding, or with "=" or another byte outside the alphabet in a group of
four ahead of the last group, gets no message. In the last group, a byte
from "(" to DEL outside the alphabet reads as -1, all bits set, and the
bytes are built from it with a sign-extending shift: Y=Q= is FF F4 and
=YQ= is FD 84. Any other byte there gets no message. A last character
ahead of the padding with bits past the last byte, which -1 always has,
gets "Invalid last non-pad Base64 character dectected". DynamoDB reads
these values in an item, in an expression attribute value and in a
PartiQL parameter. Its BS duplicate text gives each member as the base64
of its bytes: ["Y=Q=", "//Q="] gets "Input collection [//Q=, //Q=]".
The echo of a BatchExecuteStatement or ExecuteTransaction list past its
limit prints such a parameter as the buffer of its bytes,
java.nio.HeapByteBuffer[pos=0 lim=2 cap=2] for Y=Q=. Measured in
us-east-1 on 21 Nov 2026.
decode_with now calls one function for these steps when the standard
decoder refuses a value, for decode_base64 and decode_padded_base64. The
function gives the bytes or the text, and replaces the match that picked
the text. A value the standard decoder reads takes the same path as
before. The BS duplicate text gives each member as the base64 of its
bytes. The echo now decodes a B as the PartiQL parameter check does,
with decode_padded_base64. It used the standard decoder, and printed
b=null for such a value.
Fixes #1307.
DynamoDB's BatchWriteItem reads the B value Y=Q= in a PutRequest item and stores it as //Q=. Measured in us-east-1 on 2026-11-22, each request twice: the write answered 200 and a GetItem gave the B value //Q=. The decoder that requires the padding takes the second reading on this branch, so the operation gives the same answer here. The row joins the table of the padding test, which the fix of #1258 added without it. Refs #1307.
The base adds the rows "//==" and "++==" to the decoder tests, with their date, and merges #544's branch through #1260. This branch moves the test module of crates/core/src/types/attribute_value.rs to attribute_value/tests.rs, so the base's change to that module conflicts. The merge keeps this branch's attribute_value.rs. It makes the base's three changes in tests.rs: the dates in the doc comment of a_value_that_is_not_base64_gets_the_service_text, its row count (now 156), and the two rows. The docstring of tests/test_binary_base64.py conflicts too. The merge keeps this branch's docstring and adds the date 2026-11-25.
binary_set decoded each member of a set to find duplicates, then decoded each member a second time to print the duplicate text. The second decode could not fail, because the first decode read every member. binary_set now keeps the decoded members, prints the duplicate text from them and builds the set from them. The answers do not change.
…descriptor
set_fault reads an ExpressionAttributeValues value that has a second
type descriptor. For an SS or a BS that holds a member twice, it gave
the text of the AttributeValue deserializer. An earlier commit of this
branch changes that text to a sorted list with quotes, which PutItem
gives. On this path the service lists the members as sent. Measured on
2026-11-25, each body twice, with :z as the key condition value:
{"SS": ["b", "a", "b"], "N": "1"}
... Input collection [b, a, b] contains duplicates. for key :z
{"BS": [the base64 of b, a and b], "N": "1"}
... Input collection [Yg==, YQ==, Yg==]of type BS contains
duplicates. for key :z
After the merge with #1355's branch, ExtendDB gave the sorted text, and
a_number_fault_in_a_value_with_several_types_is_named_ahead_of_the_several_types_text
and six rows of tests/test_query_value_shapes.py failed.
set_fault now takes the text of duplicates_as_sent, as BatchWriteItem
does. It lists the members of an SS or a BS as sent. Its NS text is the
text that set_fault gave before. The deserializer still gives the text
for an empty set.
navareamol
left a comment
There was a problem hiding this comment.
I found no code defect in this PR. Two description points and one CI point:
-
The description says the rows are in
tests/test_binary_base64.py: "108 PutItem values with=or another byte at each place of a group", "7 values that end in four to seven=" and "3BSsets". I count +102 rows in that file against #1313's head: 100put(...)rows (the 7 trailing=rows among them), onequeryrow and onestatementrow. The file has no newBSrow. The three sets are inattribute_value/tests.rs(lines 626 to 640). Could the description say where each group is and how many rows are committed? -
The new Python rows send each value to a table that does not exist and expect
ResourceNotFoundException, so they check that the value is read, not what is stored. The bytes FF F4 are checked by the unit rows and by the BatchWriteItem roww3. I sentY=Q=over the wire to a SQLite build of this head: PutItem, BatchWriteItem, TransactWriteItems Put, UpdateItem SET and UpdateItem AttributeUpdates all store and return//Q=, and the keysY=Q=and//Q=are one item. Would you add one wire row that writesY=Q=and reads//Q=back? -
The
wasmcheck on this head fails with E0308 atcrates/core/src/metrics/collector.rs:60, the error main had before #1482. TheTestrun is on attempt 3: attempt 1 failed inextenddb-auth(secmem::init_refuses_under_a_low_memlock_limit_then_starts_unlocked) and attempt 2 inextenddb-cache(tests::refresh_dropped_when_hard_miss_races), and neither test is in this diff. The head merges with current main (92155f3) with no conflict, and on that mergecargo check --workspace --all-targets, clippy on core and engine, fmt, and the core (1243) and engine (980) lib tests pass. Could you merge main so CI runs on it?
Behaviour I checked and found right: the five steps in the description against 3209 random values over the wire (3208 agree, the one difference was my model), 2201 probes in every position that reads a B (item, key, expression value, ExclusiveStartKey, Expected, KeyConditions, QueryFilter, ScanFilter, AttributeUpdates, transactions, BatchWriteItem, PartiQL) with no 5xx, and six reverted fixes that each make a PR test fail.
Has anyone sent Y=Q= to BatchWriteItem, UpdateItem and a PartiQL INSERT parameter on the real service?
I will approve once the description names where the rows are and CI has run on a branch with current main.
The base merges main at 01556cf, 27 commits past 14ade59, through #1260, and checks only the items and keys of BatchWriteItem for padding. The merge has no conflict. Git merged two files with changes on both sides: - crates/core/src/types/attribute_value.rs: the base changes check_binaries, and this branch adds second_reading and moves the test module to attribute_value/tests.rs. - crates/engine/src/batch_write_item/padding_tests.rs: the base adds the test of the items and keys and the helpers tables and answer. This branch adds the row w3 and a sentence of the module comment.
Your question about the service: on 22 November 2026, BatchWriteItem stored |
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.
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 #1355. It gives the 1.1.0 text and the texts of DynamoDB for an SS, a BS and an NS. It also names the operations that add the prefix, and gives the texts of BatchWriteItem.
|
Row w3 does not send a request over HTTP. It calls the engine's dispatch function on a SQLite engine, so it covers BatchWriteItem only. No committed row stores Y=Q= through UpdateItem SET, TransactWriteItems or a PartiQL INSERT and reads //Q= back. The Python rows send Y=Q= to a table that does not exist and expect ResourceNotFoundException, and the unit rows check the decoder and the BS duplicate text. I would add one Python row in tests/test_binary_base64.py that creates a table, writes Y=Q= through UpdateItem SET and through an ExecuteStatement INSERT, and reads //Q= back with GetItem. I will not hold the approval on it, because the behaviour is right (below). I built 5ab515c with SQLite and sent Y=Q= over the wire to a real table. PutItem, BatchWriteItem, UpdateItem SET, UpdateItem AttributeUpdates, TransactWriteItems Put, ExecuteStatement INSERT, BatchExecuteStatement INSERT and ExecuteTransaction INSERT all answer 200, and GetItem returns //Q= each time. On #1313's head 6512dcd the same eight requests answer SerializationException and store nothing. The seven files of this PR are identical on 5c724e5, so this holds for the current head. Your counts match the diff: 102 new rows in tests/test_binary_base64.py (100 put, one query, one statement), 7 of the puts with four to seven "=", the 3 BS sets at lines 626 to 640 of attribute_value/tests.rs, and the echo rows in tests/test_partiql_requests.py. The description now says where each group is. BatchWriteItem members that #1313 skips behave as before. A B or BS member beside Item or Key, and an attribute named B or BS, give the same status, code and message on 5ab515c and on 6512dcd for ordinary values. Where the two builds differ, the value is Y=Q= or =YQ=, which 6512dcd cannot read, and the head answers as PutItem does. I also ran my own probes (about 3200 values through PutItem and 2200 probes across the operations that read a B) on the head: no 5xx. One value, BA=, answers 200 where my model expected a length error. I think my model is wrong there, since #1313 reads it as unpadded. I checked the wording of the new upgrade manual entry against the wire (YQ====== and Y=======, A=B= and Y=R=, the BS duplicate text) and it matches. You wrote that the live DynamoDB rows for BatchWriteItem (22 November), and the ResourceNotFoundException answers of 2 December for BatchWriteItem, UpdateItem SET and ExecuteStatement INSERT, are your measurements. I have not repeated them. The stored bytes for UpdateItem and INSERT on the real service are not measured. Has anyone created a table and read them back? On CI, main c8e66fb is in the head now, and wasm, clippy, fmt, run-tests (stable and 1.94.0) and the wire jobs pass. The integration, cassandra, mongodb and postgres storage jobs were still queued or running when I looked, and none had failed. I will approve once the remaining CI jobs on 5c724e5 finish green. |
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.
The new test in tests/test_binary_base64.py creates a table on the server under test. It writes Y=Q= with UpdateItem SET and with an ExecuteStatement INSERT, then reads //Q=, the bytes FF F4, back with GetItem. Row w3 of padding_tests.rs covers BatchWriteItem only, through the engine's dispatch function. pytest skips the test against DynamoDB. There, both writes read Y=Q= (ResourceNotFoundException on a table that does not exist, measured 2026-12-02). No one created a table there to read the stored bytes back.
The base changes one sentence of its v1.2.0 entry. It now says that 1.1.0 answered such a BatchWriteItem request with the text of the other fault. The merge has no conflict.
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.
|
No. No one created a table on the service to read back the bytes that UpdateItem SET or an INSERT stores for 874a372 adds the row you suggest to ac0e139 merges #1313's head 6825c8e, which changes the BatchWriteItem check inside a value (see the answer there). 72c5f60 merges #1313's head 835b5ae, which changes one sentence of its entry. The new head is 72c5f60. |
|
The row for UpdateItem SET and ExecuteStatement INSERT is in, and it runs. The 1313 commits merged into this head are the ones I checked in #1313. The manual sentence about 1.1.0 matches a build of tag v1.1.0 (details on #1313). Three checks are still pending on 72c5f60: integration, cassandra-pytest (1) and mongodb-integration. None has failed. mongodb-rust passes here. The same job failed on #1313 in A merge of current main (c057660) conflicts in docs/manuals/07-upgrade-manual.md, because #1446 added an entry just above the one this stack edits. This shows when the stack lands. I will approve once the three pending checks finish green. |
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.
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.
navareamol
left a comment
There was a problem hiding this comment.
b87dc2e is a merge of #1313's new head. Compared with 72c5f60, the only file under crates or tests that differs is tests/test_binary_base64.py, which gains the 15 rows of #1260. The code and tests of this PR did not change, and the rest of the diff is main.
On a SQLite build of this head, 5707 wire tests passed and 2 failed. Both failures are my own comparison tests, each on the one value BA=, where my model expects a length error and the server answers 200. I think my model is wrong there, since #1313 reads an unpadded value, and I see no defect in this PR. The file now has 171 rows, and the 15 new ones pass on this head.
Main moved 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 b87dc2e, so I approve.
Changes since the last review
tests/test_binary_base64.py, which now has 171 rows. One file conflicted:docs/manuals/07-upgrade-manual.md. fix(storage-mongodb): keep a DELETING table's tags until its document goes #1446 and fix(storage-cassandra): retry a lost UpdateItem version check over the PutItem and DeleteItem window #1531 add two v1.2.0 entries at the top of "Behavior Changes by Release", where this PR adds its entry. The merge keeps the two entries of main first, then the entry of this PR, then the entry of fix(core): read a B value with its padding left out or cut short #1313. Git mergedtests/test_binary_base64.pyat other lines. No other file has changes on both sides.cargo +1.97.0 fmt --all -- --checkis clean..github/workflows/clippy.ymlwith-D warningsare clean onextenddb-coreandextenddb-engine.tests/test_binary_base64.pyandtests/test_partiql_requests.pypassed 244 tests.python3 -m pytest --collect-only -qcollects 7480 tests intests/and 820 intests/pythonwith no error.cargo +1.94.0 check, the wasm-adapter tests and the WebAssembly clippy step pass there too.The message of 731520b says that
decode_withcalls one function for these steps "when the standard decoder refuses a value, for decode_base64 and decode_padded_base64". That function issecond_reading, anddecode_base64tries the decoder that reads a value without its padding first, as the What section below says. The history stays as the reviewers saw it. Whoever merges: please use the What section of this body as the squash message.What
ExtendDB now reads and refuses a
Bvalue with=or another byte inside, as DynamoDB does. Before this change, a value such asY=Q=or=YQ=got aSerializationExceptionwith no message, and DynamoDB stores bytes for it.When the standard decoder refuses a
Bvalue or aBSmember, DynamoDB reads the value a second time. The new functionsecond_readingincrates/core/src/types/attribute_value.rsdoes the same steps:Base64 encoded length is expected a multiple of 4 bytes but found: <n>.=at the end are the padding. A value without padding, or with=or another byte outside the alphabet in a group of four ahead of the last group, gets no message.(to DEL outside the alphabet reads as -1, with all bits set. Any other byte there gets no message.Y=Q=is FF F4 and=YQ=is FD 84.Invalid last non-pad Base64 character dectected. A -1 there always gets it.decode_base64anddecode_padded_base64each callsecond_readingwhen their own decoder refuses a value: the decoder that reads a value without its padding fordecode_base64, the standard decoder fordecode_padded_base64. It gives the bytes or the refusal text, and it replaces thematchthat picked the text. A value that the standard decoder reads takes the same path as before. #1260's two special cases stay: a value of one byte getsBuffer is too short for base64 encoding, and==gets no message.The decoded bytes also change these answers:
BSduplicate text gives each member as the base64 of its bytes.["Y=Q=", "//Q="]getsInput collection [//Q=, //Q=]of type BS contains duplicates.Bparameter withdecode_padded_base64, as the parameter check does. It printsY=Q=asjava.nio.HeapByteBuffer[pos=0 lim=2 cap=2]. Before, it used the standard decoder and printedb=null.The first commit moves the test module of
attribute_value.rstoattribute_value/tests.rswith no other change. At #1313's head 6512dcd the file has 891 lines. After this PR it has 427 lines, andattribute_value/tests.rshas 646.The base of this PR is #1313.
Why
Fixes #1307
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 and GetItem rows used an on-demand table, which the measurement created and deleted.
Base64 encoded length is expected a multiple of 4 bytes but found: <n>.Invalid last non-pad Base64 character dectected.SerializationExceptionwith no message.BvalueY=Q=,A=Q=,==Q=, orY?Q=for any byte?from(to DEL outside the alphabet//Q=//Q==YQ=,,YQ=/YQ=/YQ=YWJj=YQ=,YWJjY-Q=YWJj/YQ=andYWJj//Q=A=B=,Y=R=,=Y==,Y,==,YQ,=YQ======,Y=======Y=QA,YQ=A,Y-QAYWJj,Y!Q=,Y Q==YQ,YWJjY=The table shows a sample. The measurement holds these rows:
=or another byte at each place of a group.=.BSsets.YQ==,Y=Q=and=YQ=in a BatchExecuteStatement list of 26 statements and an ExecuteTransaction list of 101.The committed rows are in these places:
tests/test_binary_base64.py: 102 new rows. 100 are PutItem values, and the 7 values that end in four to seven=are among them. One row is a Query and one an ExecuteStatement. The file has no newBSrow. It also hastest_update_and_insert_store_y_q_as_ff_f4, which runs against ExtendDB only (see "Changes since the last review").a_value_that_is_not_base64_gets_the_service_textincrates/core/src/types/attribute_value/tests.rs: the 100 new decoder rows, and the 3BSsets at lines 626 to 640.tests/test_partiql_requests.py: the echo rows.The rows also went to a table that does not exist. Each value got the same refusal there, and a value that DynamoDB stores got
ResourceNotFoundException. The Python rows send their PutItem that way. #1313 gives DynamoDB's answer to 58 of the 119 rows on a table that exists, and this PR gives it to all of them.Other paths and #1312
This PR changes the ExtendDB column of #1312. For
["Yg==", "Yg"], ExtendDB now givesInput collection [Yg==, Yg==]in place of[Yg==, Yg]. DynamoDB's1 validation error detected:start and its quoted members are still #1312.ImportTable with the
DYNAMODB_JSONformat does not take the second reading of aBvalue. DynamoDB's import refusesY=Q=and the other values of this issue, measured on 22 November 2026. #1313 keeps ExtendDB's import on the standard decoder, and this branch merges that commit.BatchWriteItem reads a
Bvalue with the decoder that requires the padding, through the check that #1313 adds. With this PR that decoder takes the second reading. So BatchWriteItem storesY=Q=as//Q=, as DynamoDB does, measured on 22 November 2026. The commit 7b97b2a adds this row to the padding test of #1313.Conflicts
git merge-treeshows no conflict withmainor with #1313 and #1260. The change in the imports ofcrates/engine/src/partiql/request_checks/echo.rsadds one conflict hunk with #781. The resolution keeps #781's two lines,use extenddb_core::map_order::hash_map_order;anduse serde_json::Value;, without the twobase64lines.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 also adds a conflict in
crates/core/src/types/attribute_value.rswith #1377 and the three PRs stacked on it: #1381, #1418 and #1437. #1377 and #1418 change tests in the module that this PR moves toattribute_value/tests.rs. On a rebase, apply their test changes intests.rs.Not in this PR
Testing done
All runs below are on f8489dc, before the merges of #1313'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 --lib: 1147 passed, 1 ignored.cargo +1.97.0 test -p extenddb-engine --lib: 930 passed.cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warnings, the same forextenddb-enginewith--features extenddb-engine/backup-test-hooks, the same forextenddb-corewith--no-default-features,cargo +1.91.1 check -p extenddb-core -p extenddb-engine --all-targetsandcargo +1.97.0 fmt --all -- --checkare clean.cargo +1.97.0 clippy --locked -p extenddb-wasm-adapter --lib --release --target wasm32-unknown-unknown -- -D warnings, is clean.a_binary_is_echoed_as_the_buffer_of_its_bytesfails: its first new row getsb=null.a_value_that_is_not_base64_gets_the_service_textfails at the set["Y=Q=", "//Q="].decode_base64anddecode_padded_base64of f8489dc and of fix(core): read a B value with its padding left out or cut short #1313's head. A reference written from the steps above gave the same answer as f8489dc to every value. fix(core): read a B value with its padding left out or cut short #1313 differed from it on 24,309 values for each decoder. The values were these:["Yg==", "Yg"], the duplicate text of A BS with two spellings of one value gets another duplicates text than DynamoDB's #1312. Each row went out twice with the same answer both times.tests/test_binary_base64.py,tests/test_partiql_requests.pyand the Python files with otherBrows (tests/test_attribute_value_validation.py,tests/test_query_value_shapes.py,tests/test_item_operations.py,tests/test_partiql_write.py,tests/test_partiql_batch.py) passed 1104 tests.tests/test_query_leading_keys_values.pypassed 2.Line counts, with the test files and the lines after
#[cfg(test)]counted as tests:Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, 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
ExtendDB now stores bytes for a
Bvalue with=or another byte inside, as DynamoDB does, where it answered a SerializationException with no message before. Some values get another refusal text, as the table in Why shows. TheBSduplicate text and the echo of a long BatchExecuteStatement or ExecuteTransaction list give the decoded bytes. The stored data does not change. The v1.2.0 entry ofdocs/manuals/07-upgrade-manual.mdgives 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.