Skip to content

fix(core): give a set with duplicate members DynamoDB's text - #1368

Open
LeeroyHannigan wants to merge 16 commits into
fix/1307-base64-inner-charactersfrom
fix/1312-set-duplicates
Open

LeeroyHannigan wants to merge 16 commits into
fix/1307-base64-inner-charactersfrom
fix/1312-set-duplicates

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

A set that holds a member twice now gets DynamoDB's text. OOM is One or more parameter values were invalid: .

  • The members ahead of the first repeated member come first, sorted, and the rest follow as sent. An SS compares code points, and a BS compares unsigned bytes.
  • An SS lists its members with quotes, as Rust's Debug prints a list of strings: OOM Input collection ["a", "b", "b"] contains duplicates.
  • A BS lists the padded base64 of its members as a JSON array, with of type BS right after it: OOM Input collection ["YQ==","Yg==","Yg=="]of type BS contains duplicates.
  • An NS names no member: OOM Input collection contains duplicates. Members equal as numbers, such as 1 and 1.0, are duplicates.
  • PutItem, UpdateItem and DeleteItem put 1 validation error detected: ahead of the text. TransactWriteItems, Query and Scan do not.
  • The text changes for a set in a GetItem, BatchGetItem, TransactGetItems or DeleteItem key, a Query or Scan ExclusiveStartKey, or a KeyConditions or Expected value.
  • BatchWriteItem lists the members of an SS or a BS as sent, in an item and in a DeleteRequest key. The text is OOM Input collection [b, a, b] contains duplicates. Its NS text is Input collection contains duplicates, with no start and no period.
  • ExecuteStatement, BatchExecuteStatement and ExecuteTransaction give the texts of BatchWriteItem for a set in a parameter, as before this PR.
  • Beside a second type descriptor in the ExpressionAttributeValues of a Query, a set gets the text of BatchWriteItem, wrapped as ExpressionAttributeValues contains invalid value: ... for key :z. A BS member without its padding gets the sorted text there, where DynamoDB answers SerializationException (Two type descriptors: DynamoDB answers a fault in any payload, a nested value or a PartiQL parameter, where ExtendDB answers the descriptor count #1404). A Scan answers the more than one datatypes text for such a value, as before this PR.
  • A BS with a member that only the second reading of fix(core): read a B value with "=" or another character inside #1355 decodes, such as Y=Q=, keeps the text of fix(core): read a B value with "=" or another character inside #1355. That text lists the members as sent, with no prefix.

The deserializer in crates/core/src/types/attribute_value.rs gives the listed texts. single_write_refusal in crates/engine/src/lib.rs adds the prefix for the three single-item writes, with the existing SINGLE_WRITE_PREFIX. BatchWriteItem reads the items and keys of its raw RequestItems once more (written_values, from #1313) for the first SS or BS with a repeated member. It skips number sets, whose text names no member. The PartiQL parameter checks call the same as-sent function, and so does the set check of ExpressionAttributeValues beside a second type descriptor. Their texts do not change. The PartiQL number set check is gone.

The base of this PR is #1355.

Why

Fixes #1312
Fixes #1360

These are DynamoDB's answers, measured in us-east-1 on 22 November 2026 with signed requests. Each request went out twice and got the same answer both times. Each answer is a ValidationException. PREFIX is 1 validation error detected: .

Request DynamoDB ExtendDB on #1355
PutItem, SS ["b", "a", "b"] PREFIX OOM Input collection ["a", "b", "b"] contains duplicates. OOM Input collection [b, a, b] contains duplicates.
PutItem, BS ["Yg==", "YQ==", "Yg=="] PREFIX OOM Input collection ["YQ==","Yg==","Yg=="]of type BS contains duplicates. OOM Input collection [Yg==, YQ==, Yg==]of type BS contains duplicates.
PutItem, SS with U+E000, U+1F600 and U+E000 PREFIX OOM Input collection ["\u{e000}", "😀", "\u{e000}"] contains duplicates. OOM, then the three members as sent, without quotes
PutItem, NS ["1", "1.0"] PREFIX OOM Input collection contains duplicates. OOM Input collection [1, 1.0] contains duplicates.
UpdateItem, SS ["b", "a", "b"] PREFIX OOM Input collection ["a", "b", "b"] contains duplicates. OOM Input collection [b, a, b] contains duplicates.
TransactWriteItems or Query, SS ["b", "a", "b"] OOM Input collection ["a", "b", "b"] contains duplicates. OOM Input collection [b, a, b] contains duplicates.
BatchWriteItem, SS ["b", "a", "b"] OOM Input collection [b, a, b] contains duplicates. the same
BatchWriteItem, NS ["1", "1.0"] Input collection contains duplicates OOM Input collection [1, 1.0] contains duplicates.
PutItem, BS ["Y=Q=", "YQ==", "//Q="] OOM Input collection [//Q=, YQ==, //Q=]of type BS contains duplicates. the same

The table shows a sample of 55 measured requests:

Of these, #1355 gives DynamoDB's answer to 22, and this PR to 54.

The one request that still differs has an SS with a repeat in the attribute s and an NS with a repeat in n. DynamoDB reports the SS, the first in request order. ExtendDB reports the NS, because the SQLite build reads the attributes of an item in name order. #1355 has the same order, and this PR changes only the text of the set it reports.

The rows below are DynamoDB's answers of 25 November 2026, measured in the same way, on a table that does not exist. The key is pk, and SET is {"SS": ["b", "a", "b"]}. This PR gives each of these answers.

Row Request DynamoDB
R1 PutItem, s {"SS": ["b", "a", "b", "d", "c"]} PREFIX OOM Input collection ["a", "b", "b", "d", "c"] contains duplicates.
R2 PutItem, s {"SS": ["\"", "\\", "\""]} PREFIX OOM Input collection ["\"", "\\", "\""] contains duplicates.
R3 GetItem, key SET OOM Input collection ["a", "b", "b"] contains duplicates.
R4 BatchGetItem, key SET the same as R3
R5 TransactGetItems Get, key SET the same as R3
R6 DeleteItem, key SET PREFIX OOM Input collection ["a", "b", "b"] contains duplicates.
R7 Query, ExclusiveStartKey SET the same as R3
R8 Query, KeyConditions EQ SET the same as R3
R9 PutItem, Expected s Value SET the same as R6
R10 BatchWriteItem DeleteRequest, key SET OOM Input collection [b, a, b] contains duplicates.
R11 Query, :z {"SS": ["b", "a", "b"], "N": "1"} ExpressionAttributeValues contains invalid value: OOM Input collection [b, a, b] contains duplicates. for key :z
R12 Query, :z the BS of the base64 of b, a and b, with "N": "1" ExpressionAttributeValues contains invalid value: OOM Input collection [Yg==, YQ==, Yg==]of type BS contains duplicates. for key :z

R1 shows that the members after the repeat stay as sent, and R2 shows the escapes of a quote and a backslash.

The rows below are DynamoDB's answers of 2 December 2026 (R13 to R15) and 3 December 2026 (R16), measured in the same way. This PR gives each of these answers.

Row Request DynamoDB
R13 BatchWriteItem PutRequest with "A": {"SS": ["q", "q"]} beside its Item, and s SET in the item OOM Input collection [b, a, b] contains duplicates.
R14 PutItem, s {"SS": ["\t", "\n", "\u0001", "\u0000", "\t"]} PREFIX OOM Input collection ["\0", "\u{1}", "\t", "\n", "\t"] contains duplicates.
R15 PutItem, s {"SS": ["\u0301", "a\u0301", "\u0301"]} PREFIX OOM Input collection ["a\u{301}", "\u{301}", "\u{301}"] contains duplicates.
R16 PutItem, s {"SS": ["\u2028", "\u0085", "\u007f", "\u200d", "\u202e", "\uffff", "\ud83d\ude00", "'", "\u4e2d", "\u2028"]} PREFIX OOM Input collection ["'", "\u{7f}", "\u{85}", "\u{200d}", "\u{2028}", "\u{202e}", "中", "\u{ffff}", "😀", "\u{2028}"] contains duplicates.

R13 shows that the service does not read a member that PutRequest does not model. R14 and R15 show the escapes of a control character and of a combining mark, also after another character. R16 shows the escapes of DEL, U+0085, U+200D, U+2028, U+202E and U+FFFF. An apostrophe, a CJK character and an emoji stay as they are.

Not in this PR

  • A BS member without its padding beside a second type descriptor in ExpressionAttributeValues. Measured on 2 December 2026, Query with :z set to {"BS": ["Yg==", "YQ==", "Yg"], "N": "1"} gets SerializationException Base64 encoded length is expected a multiple of 4 bytes but found: 2, and this PR gives the duplicates text (Two type descriptors: DynamoDB answers a fault in any payload, a nested value or a PartiQL parameter, where ExtendDB answers the descriptor count #1404).

  • The order of the attributes of an item on the SQLite, PostgreSQL and Cassandra builds (the request above).

  • From the code, not measured: the PutItem error mapping lacks the contains invalid key and contains invalid value texts of deserialize_error. So a refusal such as ExpressionAttributeNames contains invalid value: ... may get another exception type on PutItem than on the other operations.

  • A Scan ExclusiveStartKey gets the same text as a Query one, from the same deserializer, and is not measured.

Conflicts

git merge-tree shows no conflict with main. 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. In the code, this PR adds conflicts with four open PRs.

Testing done

The runs below are on bb1050e, before the merges of #1355'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 test -p extenddb-core -p extenddb-engine --lib --no-fail-fast: 1148 core unit tests passed and 1 ignored, and 931 engine unit tests passed.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warnings, the same with --features extenddb-engine/backup-test-hooks, and cargo +1.91.1 check -p extenddb-core -p extenddb-engine --all-targets are clean.
  • A control puts back the production files of fix(core): read a B value with "=" or another character inside #1355's head and keeps the tests. Then 18 of the 24 rows of the core table fail: D1 to D16, N1 and N2. 24 of the 29 rows of the engine table fail: O1 to O4, O6 to O13, O15 to O17, and R1 to R9. O5, O14, O18, P1 and R10 pass, because fix(core): read a B value with "=" or another character inside #1355 gives those answers already.
  • A second control makes set_fault take the as-sent text for an NS only, as before 13d3e5a. Then a_number_fault_in_a_value_with_several_types_is_named_ahead_of_the_several_types_text fails at {"N": "1", "SS": ["a", "a"]}, and 6 rows of TestValuesTheServiceCannotReadAsOneType in tests/test_query_value_shapes.py fail: SS dup then N 1, SS dup then N bob, SS dup then X, SS dup then L with null, S then L with SS dup and BS dup then N 1. R11 and R12 get the sorted text.
  • Against a SQLite build of bb1050e, the 55 requests of the Why section got the answers it counts. R1 to R12 got DynamoDB's answers. Nine Python files passed 1240 tests, with 2 expected failures: tests/test_attribute_value_validation.py, tests/test_binary_base64.py, tests/test_partiql_requests.py, tests/test_query_value_shapes.py, tests/test_batch_write_validation_order.py, tests/test_partiql_batch.py, tests/test_partiql_phase3.py, tests/test_partiql_transaction.py and tests/test_partiql_write.py.
  • Scratch merges with the heads of fix(scan): report every Limit, Segment and TotalSegments range fault in the service's two forms #850 and fix(scan): check AttributesToGet, ScanFilter, ExclusiveStartKey and ExpressionAttributeValues in the service's order #854, resolved as the Conflicts section says, passed the core and engine unit tests.
  • The WebAssembly clippy step of devtools/run-wasm-step clippy is clean on a scratch merge of bb1050e with main (fec675db4). bb1050e lacks devtools/wasm-clippy, which feat(wasm): [Add WebAssembly browser support for ExtendDB #1009 added on main.
  • python3 -m pytest --collect-only -q collects 7168 tests in tests/ and 672 in tests/python, with no error.
  • Runs on the reviewed head 69b76da, before the merge: 1008 random requests went to that commit and to fix(core): read a B value with "=" or another character inside #1355's head of that day, 7b97b2a. They held 42 sets on 8 operations, at the top level and inside M and L values. Each request that the rule covers got the rule's answer, and no answer that matched DynamoDB on fix(core): read a B value with "=" or another character inside #1355 changed. Every ExecuteStatement answer is the same on both. The extra BatchWriteItem read takes 1.78 ms on a request of 25 items with 750,000 number set members. It takes 27.7 ms on a request with 105,000 binary set members. The deserializer takes 306 ms and 47 ms on the same requests.

At 9d56bbe against #1355's head 874a372, production is +218 -79, the tests are +372 -1, and the upgrade manual is +15. These count the Rust lines of an inline test module as tests. The commit 2605716 is +5 -4 in production and +13 -1 in the tests. a25b27a adds 14 lines to the upgrade manual.

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

  • The message of the refusal of a set that holds a member twice changes on the operations that the What section names. The status and the __type do not change. A client that matches the message text gets the texts above. The v1.2.0 entry of docs/manuals/07-upgrade-manual.md gives this change.

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 gave its own text for a set that holds a member twice. An SS or
an NS listed its members as sent, without quotes. A BS listed each member
as the base64 of its bytes. No operation put "1 validation error
detected: " ahead of the text.

DynamoDB lists the members in another order. Measured in us-east-1 on
2026-11-22, each request twice. The members ahead of the first member
equal to an earlier one come first, sorted. That member and the members
after it follow, as sent. PutItem of the SS [b, a, b] gives this text:

    1 validation error detected: One or more parameter values were
    invalid: Input collection ["a", "b", "b"] contains duplicates.

An SS is printed as Rust's Debug prints a list of strings, so U+E000 is
printed as \u{e000}. Its members compare by code point. A BS is printed
as the JSON array of the padded base64 of its members. "of type BS
contains duplicates." follows it with no space before "of". Its members
compare as unsigned bytes. The text of an NS names no member, and
members equal as numbers, such as 1 and 1.0, are duplicates.

PutItem, UpdateItem and DeleteItem put "1 validation error detected: "
ahead of the text. This holds for an item at any depth, for
ExpressionAttributeValues and for AttributeUpdates. TransactWriteItems,
Query and Scan give the text without it.

A BS can hold a member that only DynamoDB's second reading of a B value
decodes, such as Y=Q=. Such a BS keeps the earlier text on every
operation measured. Its members are listed as sent, with no prefix.

BatchWriteItem lists the members as sent. The SS [b, a, b] gives "Input
collection [b, a, b] contains duplicates." after "One or more parameter
values were invalid: ". The NS [1, 1.0] gives "Input collection contains
duplicates", without that start and without a period.

The deserializer now lists the members in DynamoDB's order. A helper in
the engine adds the prefix for PutItem, UpdateItem and DeleteItem.
BatchWriteItem finds the first such SS or BS in its raw RequestItems and
gives its text with the members as sent. Its NS text names no member, so
it compares no NS member and replaces the deserializer's NS text. The
PartiQL parameter checks call the same function and keep their texts.
The PartiQL number set check moves into it.

Fixes #1312.
Fixes #1360.
The base decodes each BS member once and merges #544's branch, which
moves the number set check of the PartiQL parameters to
validation::number. The merge resolves three conflicts:

- The imports of crates/core/src/partiql/params.rs. The base imports
  NUMBER_SET_DUPLICATES and has_equal_numbers for the PartiQL number set
  check. This branch deletes that check, so the merge keeps neither line.
- binary_set in crates/core/src/types/attribute_value.rs. Both sides
  decode each member once. The merge keeps this branch's version, which
  lists the members in DynamoDB's order.
- The attribute_value re-export list in crates/core/src/types/mod.rs.
  The merge keeps the names of both sides.

The test module of attribute_value.rs is in attribute_value/tests.rs on
both sides, so the base's new rows merge there with no conflict.
…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.
…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.
…es table

I measured ten more requests on the service on 2026-11-25, each twice,
on a table that does not exist. They cover shapes and operations that
the table did not hold:

- R1 and R2, PutItem: the members after the repeat stay as sent, and
  the text escapes a quote and a backslash.
- R3 to R6: the key of GetItem, BatchGetItem, TransactGetItems and
  DeleteItem.
- R7 and R8: a Query ExclusiveStartKey and a KeyConditions value.
- R9: a PutItem Expected value.
- R10: a BatchWriteItem DeleteRequest key, which lists the members as
  sent.

ExtendDB already gives each of these answers. The table now holds them.
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.

Git merged crates/engine/src/lib.rs, the one file with changes on both
sides. Main compiles three modules only off wasm32 (backup,
import_export_io and private_fs), and adds the modules backup_requests
and pre_dispatch. This branch adds single_write_refusal after
deserialize_error.

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

  1. In set_fault (crates/engine/src/query_key_values.rs), a set beside a second type descriptor now takes the text of duplicates_as_sent, which decodes a BS with decode_padded_base64. That is the PartiQL and BatchWriteItem decoder, but an ExpressionAttributeValues entry reads unpadded members, so a BS with an unpadded member makes duplicates_as_sent return None and the deserializer's sorted text goes out. On a SQLite build of this head, a Query with ":z": {"BS": ["Yg==", "YQ==", "Yg"], "N": "1"} answers ... Input collection ["YQ==","Yg==","Yg=="]of type BS contains duplicates. for key :z, while the same set with "Yg==" last answers ... Input collection [Yg==, YQ==, Yg==]of type BS ..., the form of R12. {"BS": ["YQ==", "YQ"], "N": "1"} answers ["YQ==","YQ=="] here and [YQ==, YQ==] on #1355's head. The description says a set beside a second type descriptor gets the text of BatchWriteItem, so I think these should list the members as sent. Could this path decode with decode_base64 (for example by passing the decoder to duplicates_as_sent), with a row for an unpadded member? If DynamoDB was measured with an unpadded member there and gives the sorted text, could that row go in the table?

  2. first_duplicates_as_sent(&body["RequestItems"]) in BatchWriteItem reads every member under RequestItems, including members the deserializer skips, so the text can name a set other than the one the deserializer refused. On this head, {"PutRequest": {"A": {"SS": ["q", "q"]}, "Item": {"pk": {"S": "k1"}, "v": {"SS": ["b", "a", "b"]}}}} answers One or more parameter values were invalid: Input collection [q, q] contains duplicates., and #1355's head and main answer [b, a, b]. An unknown member beside PutRequest in the WriteRequest does the same. The comment above the walk says it finds "the set it refused". Could the walk read only PutRequest.Item and DeleteRequest.Key of each request, in the order the deserializer reads them? check_binaries on #1313 needs the same change.

  3. The SS text follows Rust's Debug for strings. The measured rows cover U+E000, a quote and a backslash. On this head {"SS": ["\t", "\n", "\u0001", "\t"]} answers ["\u{1}", "\t", "\n", "\t"], NUL prints as \0 and a leading combining mark as \u{301}. Has anyone sent an SS with a control character or a combining mark to DynamoDB? A row for one would pin the form.

  4. CI on this head ran on 25 November 2026 and the branch is 23 commits behind main. The wasm failure is E0308 at crates/core/src/metrics/collector.rs:60:53, the error main had before #1482. The Test run passed on attempt 2; attempt 1 failed in the auth crate's secmem::init_refuses_under_a_low_memlock_limit_then_starts_unlocked, which this diff does not touch. The head merges with current main (92155f3) with no conflict, and on that merge cargo check on the workspace with all targets, clippy on core and engine, fmt, and the core (1244) and engine (981) lib tests pass. Could you merge main so CI runs on it?

Behaviour I checked and found right: sets with a repeated member (1 with 1.0, 01, 1e0 and 1E0, 10 with 1e1, YQ== with YQ and YQ=, Y=Q= with //Q=, sets of 3000 members) in items, keys, expression values, ExclusiveStartKey, the legacy parameters, transactions, BatchWriteItem, PartiQL parameters, and UpdateItem ADD and DELETE. Each is refused with no 5xx and nothing stored, ADD and DELETE of an equal member written another way keep one member or remove it, the PartiQL texts match #1355's, and six reverted fixes each make a PR test fail.

I will approve once 1 and 2 list the members as sent (or a DynamoDB row shows otherwise) and CI has run on a branch with current main.

The base merges main at 01556cf, 27 commits past 14ade59, through
#1260. It also checks only the items and keys of BatchWriteItem for
padding, through padding_refusal in batch_write_item.rs.

One file conflicted: crates/engine/src/batch_write_item.rs. The import
list keeps the names of both sides. handle_batch_write_item first runs
the padding check of the base. Then it runs the walk of this branch for
the first set with a repeated member.

Git merged four files with changes on both sides, at other lines:

- crates/core/src/types/attribute_value.rs: the base changes
  check_binaries, and this branch adds the duplicates texts.
- crates/engine/src/batch_write_item/padding_tests.rs: the base adds a
  test and the helpers tables and answer. This branch makes context
  pub(super).
- crates/engine/src/lib.rs: main adds three modules and their exports,
  and this branch adds single_write_refusal.
- crates/engine/src/query_key_values.rs: the base makes shape_fault
  pub(crate), and this branch changes set_fault.
…keys

BatchWriteItem replaces the sorted duplicates text of the deserializer
with the members as sent of the first set with a repeated member. The
walk read every member under RequestItems, so a set in a member that
the deserializer skips could give the text. For example, a PutRequest
with {"A": {"SS": ["q", "q"]}} beside its Item answered [q, q]. The
deserializer refused the set [b, a, b] of the item.

The walk now reads written_values, the attribute values of each
PutRequest Item and each DeleteRequest Key that the padding check
reads too. DynamoDB answers that request with "One or more parameter
values were invalid: Input collection [b, a, b] contains duplicates."
(measured 2026-12-02, twice, on a table that does not exist).

The table of set_duplicates_tests.rs gets that request as R13. It also
gets two PutItem rows of the same day, R14 and R15, which pin the form
of an SS member. Each answer comes after "1 validation error detected: ".

- ["\t", "\n", "\u{1}", "\0", "\t"] answers ["\0", "\u{1}", "\t",
  "\n", "\t"].
- ["\u{301}", "a\u{301}", "\u{301}"] answers ["a\u{301}", "\u{301}",
  "\u{301}"].
The base merges main at e8b5f10 through #1260, which brings #481,
#1137 and #1403. The merge has no conflict. Main adds a test module to
crates/engine/src/lib.rs, where this branch adds single_write_refusal,
at other lines.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. Measured on 2 December 2026 with Query, twice each, on a table that does not exist: ":z": {"BS": ["Yg==", "YQ==", "Yg"], "N": "1"} and {"BS": ["YQ==", "YQ"], "N": "1"} answer SerializationException with Base64 encoded length is expected a multiple of 4 bytes but found: 2. So do {"BS": ["YQ"], "N": "1"} and {"B": "YQ", "N": "1"}, which hold no duplicate. Beside a second type descriptor, the service reads a B value or a BS member only with its padding. It refuses such a member ahead of the duplicate check. Neither duplicates text applies, and decode_base64 there would give a third answer. Two type descriptors: DynamoDB answers a fault in any payload, a nested value or a PartiQL parameter, where ExtendDB answers the descriptor count #1404 tracks a fault in a payload beside a second type descriptor, and these four rows go there. So the code of set_fault stays.
  2. Fixed in 2605716. The walk reads written_values, the attribute values of each PutRequest Item and each DeleteRequest Key, in the order the deserializer reads them. fix(core): read a B value with its padding left out or cut short #1313 got the same change in 6b21d47. Your request answers One or more parameter values were invalid: Input collection [b, a, b] contains duplicates. on DynamoDB (2 December, twice), and that is row R13 of set_duplicates_tests.rs. With the walk of 6a224c8, R13 fails with [q, q].
  3. Measured on 2 December with PutItem, twice each: {"SS": ["\t", "\n", "\u0001", "\u0000", "\t"]} answers ... Input collection ["\0", "\u{1}", "\t", "\n", "\t"] contains duplicates., and {"SS": ["\u0301", "a\u0301", "\u0301"]} answers ... Input collection ["a\u{301}", "\u{301}", "\u{301}"] contains duplicates., each after 1 validation error detected: . Rust 1.97 prints both lists the same way, and rows R14 and R15 pin them.
  4. The branch merges main at e8b5f10 through fix(core): read a B value with "=" or another character inside #1355 (7866b70), with fix(core): read the latency segment clock through web_time #1482 in it.

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

Copy link
Copy Markdown
Collaborator
  1. Your Query rows beside a second type descriptor are right and my request for as sent members was wrong for them. On this head a Query with ":z" set to {"BS": ["Yg==", "YQ==", "Yg"], "N": "1"} still answers the sorted text ["YQ==","Yg==","Yg=="] and {"BS": ["YQ"], "N": "1"} and {"B": "YQ", "N": "1"} answer the more than one datatypes text. You measured SerializationException with the multiple of 4 text for all four, so neither of the two duplicates texts is the target and decode_base64 would not reach it either. I agree set_fault can stay as it is, and that these four rows belong to Two type descriptors: DynamoDB answers a fault in any payload, a nested value or a PartiQL parameter, where ExtendDB answers the descriptor count #1404, which now lists them. A padded set with a repeated member beside a second descriptor, such as {"BS": ["Yg==", "YQ==", "Yg=="], "N": "1"}, lists its members as sent on this head, as the description says.

  2. The BatchWriteItem walk now reads only the Item of each PutRequest and the Key of each DeleteRequest. A member such as "A": {"SS": ["q", "q"]} beside Item no longer wins: the request answers [b, a, b] as main does, and the same holds for an unknown member beside PutRequest in a WriteRequest. Two tables, two requests, a repeated set in a second table or in a Delete key, and 25 requests with the set last all name the same set as main. With the old walk put back, R13 fails with [q, q], so the row pins the change.

  3. The Debug escapes for a control character and a combining mark are pinned by R14 and R15 from your measurements, and this head prints them as you quote. Other characters follow Rust's Debug on this head and are not in a row: U+2028 prints as \u{2028}, U+0085 as \u{85}, DEL as \u{7f}, a zero width joiner as \u{200d}, U+202E as \u{202e}, U+FFFF as \u{ffff}, while an emoji, an apostrophe and CJK print as they are. Has one of these been sent to DynamoDB? If not, I would leave them out of the table and not claim them in the upgrade entry.

  4. The new upgrade manual entry matches this head's answers for the SS, BS and NS texts, the prefix on PutItem, UpdateItem and DeleteItem only, the BatchWriteItem texts, the Y=Q= text, and the rollback line (no stored data changes). Two sentences are wider than the code. The bullet on a second type descriptor says a set gets the text of BatchWriteItem. That holds for an SS, a padded BS and an NS in a Query. A Scan answers the more than one datatypes text, and a BS with an unpadded member answers the sorted text, which differs from your measurement and is in Two type descriptors: DynamoDB answers a fault in any payload, a nested value or a PartiQL parameter, where ExtendDB answers the descriptor count #1404. Could the bullet say Query and name the unpadded case? The entry also does not say that ExecuteStatement and ExecuteTransaction keep the members as sent and an NS text with no start and no period.

  5. CI on a25b27a shows 38 checks passed and 29 still pending, none failed. The merge with main is in. The fix code is unchanged since 7866b70, where check, clippy with warnings denied, fmt, the core (1261) and engine (984) lib tests pass.

I will approve once the manual bullet on a second type descriptor is corrected and the pending checks on a25b27a finish green.

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.
DynamoDB lists the members of an SS with a repeated member in the form
of Rust's Debug. On 2026-12-03, a PutItem on a table that does not
exist sent this SS twice:

    ["\u2028", "\u0085", "\u007f", "\u200d", "\u202e", "\uffff",
     "\ud83d\ude00", "'", "\u4e2d", "\u2028"]

Both answers were this text, after "1 validation error detected: ":

    One or more parameter values were invalid: Input collection ["'",
    "\u{7f}", "\u{85}", "\u{200d}", "\u{2028}", "\u{202e}", "中",
    "\u{ffff}", "😀", "\u{2028}"] contains duplicates.

The members ahead of the repeat come sorted by code point. ExtendDB
gives this text, and the table of set_duplicates_tests.rs now holds it
as R16.
The bullet on a second type descriptor in the v1.2.0 entry held for a
Query only. It now says so. There, a BS with a member without its
padding gets the sorted text. DynamoDB answers SerializationException
with the length text of that member (#1404). A Scan answers the more
than one datatypes text for such a value, as 1.1.0 did.

A new bullet says that ExecuteStatement, BatchExecuteStatement and
ExecuteTransaction give the texts of BatchWriteItem for a set in a
parameter, as 1.1.0 did. An SS or a BS lists its members as sent, and
the NS text has no start and no period.

The SS bullet now names the characters whose form DynamoDB gave in a
measurement (2026-11-22, 2026-11-25, 2026-12-02 and 2026-12-03):

- a quote, a backslash, NUL, tab and line feed
- U+0001, DEL, U+0085, U+200D, U+2028, U+202E, U+E000, U+FFFF and a
  combining mark
- an apostrophe, a CJK character and an emoji
The base takes the docs change of fix/1258-unpadded-base64, one
sentence of its v1.2.0 entry. The merge has no conflict.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. Measured on 3 December 2026 with PutItem, twice, on a table that does not exist. The SS was ["\u2028", "\u0085", "\u007f", "\u200d", "\u202e", "\uffff", "\ud83d\ude00", "'", "\u4e2d", "\u2028"]. The answer was 1 validation error detected: One or more parameter values were invalid: Input collection ["'", "\u{7f}", "\u{85}", "\u{200d}", "\u{2028}", "\u{202e}", "中", "\u{ffff}", "😀", "\u{2028}"] contains duplicates. So the service writes each of the characters you list as this head does. e30b192 adds the row as R16 of set_duplicates_tests.rs. The SS bullet of the entry now names the characters that a measurement covers.
  2. 9d56bbe scopes the bullet to the ExpressionAttributeValues of a Query. It names the BS with a member without its padding, which gets the sorted text there. The service answers SerializationException with the length text of that member (Two type descriptors: DynamoDB answers a fault in any payload, a nested value or a PartiQL parameter, where ExtendDB answers the descriptor count #1404). The bullet also says that a Scan answers the more than one datatypes text for such a value, as 1.1.0 did. A new bullet covers ExecuteStatement, BatchExecuteStatement and ExecuteTransaction. They give the texts of BatchWriteItem for a set in a parameter, as 1.1.0 did. I sent each case twice to a SQLite build of the head, on a table that does not exist. Each got the answer that the entry gives.
  3. c3820a2 merges fix(core): read a B value with "=" or another character inside #1355's new head 874a372, which brings fix(core): read a B value with its padding left out or cut short #1313's change to the BatchWriteItem check. The one conflict was the import list of batch_write_item.rs. ff0f2a2 merges fix(core): read a B value with "=" or another character inside #1355's head 72c5f60, which brings a change of one sentence of the entry of fix(core): read a B value with its padding left out or cut short #1313. The new head is ff0f2a2.

@navareamol

Copy link
Copy Markdown
Collaborator

Point 3: R16 is in crates/engine/src/batch_write_item/set_duplicates_tests.rs with the ten members of your PutItem and the text you quote, and the SS bullet of the entry lists the characters that row covers and the ones it does not claim. That DynamoDB writes them this way is your measurement, so I am not repeating it as mine. I read the row and the bullet and found them consistent.

Point 4: the bullet on a second type descriptor now says Query, names the BS with a member without its padding, and says a Scan answers the more than one datatypes text. The new bullet for ExecuteStatement, BatchExecuteStatement and ExecuteTransaction matches the code I read in crates/core/src/partiql/params.rs, where a set in a parameter takes duplicates_as_sent, the BatchWriteItem text.

Point 5: the head merges with main as of your last merge, but main has moved to c057660 (#1446) and a merge of it into this head conflicts in docs/manuals/07-upgrade-manual.md, where main added six lines. No code file conflicts, and the head of #1313 conflicts in the same way, so this comes from main moving. On ff0f2a2, 4 checks had passed, 1 was cancelled (the PR title check, rerun and passed) and 35 were queued or running when I looked.

I will approve once main is merged and the checks on that head are green.

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 ea6a262 merges the new head of #1355, which brings main at b6c8595 through #1260. The upgrade manual conflicted where #1446 and #1531 add their entries. The merge keeps the two entries of main first, then the entry of this PR, then the entry of #1355. No code file conflicted. The checks run again on this head.

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

Main has moved again, to 5826e1b (#1087). A merge of it into ea6a262 conflicts in docs/manuals/07-upgrade-manual.md, where #1087 added the entry "SQLite parallel Scan segments follow the partition key" between the PostgreSQL TTL entry and the v1.1.0 entries. No code file conflicts, and the head of #1370 conflicts in the same way, so this comes from main moving under the stack. On ea6a262, 39 checks had passed, 1 was cancelled (conventional) and 28 were running or queued when I looked.

Your comment of 22:37 says the merge keeps the two entries of main first, then this entry, then the entry of #1355. The v1.2.0 headings at the head are in that order.

Points 3 and 4 of your last comment hold on this head. On a SQLite build of ea6a262, a PutItem with the ten members of R16 answers the text you quote, and R16 passes in the engine lib tests (985 pass). If the printing of U+200D is changed to the raw character, R16 alone fails, so the row pins it. A Query beside a second type descriptor, ExecuteStatement, BatchExecuteStatement and ExecuteTransaction answer as the entry says: the BatchExecuteStatement answer is HTTP 200 with the text in the error of the statement, and a Scan answers the more than one datatypes text. That DynamoDB writes the characters in this way is your measurement, and I have not repeated it.

All 70 checks pass on ea6a262, so I approve. The manual conflict with main sits in the whole stack, and the stack can fix it when it lands.

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