Repository navigation
fix(engine): check a ClientRequestToken as DynamoDB does - #1375
Conversation
TransactWriteItems counted the token in bytes and refused a character
outside [a-zA-Z0-9-] with a pattern text. It answered an empty token
with the maximum length text, and both texts named clientRequestToken.
DynamoDB was measured in us-east-1 on 23 Nov 2026. Each signed
TransactWriteItems request had one Put to a table that does not exist.
Each request went out twice, with the same answer both times. A token
that passes the check reaches the table lookup and gets
ResourceNotFoundException. These tokens pass:
- 36 a, and 36 é (72 bytes)
- abc_def and abc def
- abc, then U+0001, a tab or U+0000, then def
- U+0000 alone
- a backslash alone, and a backslash before 0
A token of 37 a, 37 _, 36 a and one _, or 37 é gets this answer:
1 validation error detected: Value at 'ClientRequestToken' failed
to satisfy constraint: Member must have length less than or equal
to 36
An empty token gets this answer:
1 validation error detected: Value at 'ClientRequestToken' failed
to satisfy constraint: Member must have length greater than or
equal to 1
The check now counts characters with the length rule of the
ExecuteTransaction request checks and their limit of 36. It writes the
two texts with ClientRequestToken and has no pattern check.
ExecuteTransaction runs this check after its own length check, so it no
longer refuses a token by pattern either.
Each backend stores the token for idempotency, and a PostgreSQL text
column cannot hold U+0000. The engine now doubles each backslash of the
token and writes each U+0000 as \0 before a backend sees it. Two tokens
never share this form. A token of [a-zA-Z0-9-], the only kind an earlier
build accepted, keeps its form, so the tokens such a build stored still
match. The fingerprint still uses the token as sent.
Fixes #959.
Fixes #1374.
hitesh96db
left a comment
There was a problem hiding this comment.
Required: a test that pins the stored_token call on PostgreSQL (first inline comment). I will approve once it is added.
Optional: docs/design/04-component-storage.md section 9 and docs/manuals/12-extending-extenddb-storage.md line 95 describe how a backend keys (account_id, token). The key is now the escaped form (\ doubled, U+0000 written \0) and both are unchanged. The PR body says no document describes the token check. These two describe the token store.
The branch is 12 commits behind main and lacks #526 and #774, so some replay and message differences show on the PR head alone and are fixed on main. A merge of the PR into main regresses no cell against main in 261 validation cells and 59 replay rows on SQLite, and the rows for U+0000, backslash, spaces and astral characters now match DynamoDB.
| let token = input | ||
| .client_request_token | ||
| .as_deref() | ||
| .map(super::transact_write_helpers::stored_token); |
There was a problem hiding this comment.
Nothing pins this call. With .map(super::transact_write_helpers::stored_token) changed to .map(str::to_owned) on a clean tree, cargo test -p extenddb-engine --lib --no-fail-fast passes 869 of 869. A SQLite server built with the same change answers 200 for 16 of 16 hostile tokens (U+0000, \0, \\, backslash runs) and replays each, because SQLite stores U+0000 in a TEXT key. A SQLite wire test cannot catch it either.
On PostgreSQL the same change answers a ClientRequestToken of 36 U+0000 with 500 InternalServerError, and the server log reads SQLSTATE 22021: invalid byte sequence for encoding "UTF8": 0x00. An 18 U+1F600 plus 18 U+0000 token answers the same. With the call in place both answer 200 and replay 200. No test in tests/rust or tests/*.py sends a token with U+0000 or a backslash.
Add a Python wire test that sends a token holding U+0000, one holding backslashes, and x U+0000 y against x\0y. It replays each, then sends each token with a different Put and expects IdempotentParameterMismatchException. The PR body says PostgreSQL did not run on the author's host, so this path has run on PostgreSQL only in my check.
There was a problem hiding this comment.
Added in 0b180a3. tests/test_idempotency_account_scope.py now runs one test over a table of tokens, each on a table of its own: a plain token, 28 U+0000, 14 U+1F600 and 14 U+0000, 20 backslashes, and x U+0000 y, each with a suffix unique to the run. Each token applies once, replays with 200 and no second write, and answers IdempotentParameterMismatchException for a changed request. test_nul_and_backslash_zero_are_two_tokens sends x U+0000 y and x\0y and expects two transactions. On a PostgreSQL server built from the branch, the file passes 7 tests. With .map(super::transact_write_helpers::stored_token) changed to .map(str::to_owned), the 888 engine lib tests still pass, and on PostgreSQL the four tests that send U+0000 fail with InternalServerError. The plain and backslash rows pass there, since a text column holds a backslash as sent. DynamoDB accepts these tokens: it counts the token in characters, so 36 U+1F600 pass its check and 37 get the length text (measured on 25 November, twice each). The design doc's section 9 and the storage manual now describe the stored form, as your review asked.
| } | ||
|
|
||
| // The client request token's length and pattern are checked ahead of the | ||
| // The client request token's length is checked ahead of the |
There was a problem hiding this comment.
This comment says the token is checked ahead of the actions. In this function the count check and the exactly-one-operation check run first, and the enum fields are read during deserialization before either. DynamoDB checks the token first and lists it with a count fault in one message. Measured in us-east-1 on 2026-11-24, each request twice with identical answers.
{"TransactItems": [], "ClientRequestToken": ""}
- DynamoDB:
2 validation errors detected: Value at 'ClientRequestToken' failed to satisfy constraint: Member must have length greater than or equal to 1; Value at 'TransactItems' failed to satisfy constraint: Member must have length greater than or equal to 1 - This PR and main:
1 validation error detected: Value '[]' at 'transactItems' failed to satisfy constraint: Member must have length greater than or equal to 1
One item holding both Put and Delete, with a token of 37 a:
- DynamoDB:
1 validation error detected: Value at 'ClientRequestToken' failed to satisfy constraint: Member must have length less than or equal to 36 - This PR and main:
TransactItems[0] must contain exactly one of ConditionCheck, Put, Delete, or Update
A bad ReturnConsumedCapacity with the same token also answers the token text on DynamoDB and the enum text here. main answers the same as the PR, so this is not a regression and not a condition. Narrow the comment to the faults that follow the shape checks.
There was a problem hiding this comment.
I measured your three rows again in us-east-1, each twice, on a table that does not exist, and got your answers. The comment in 0b180a3 now says that the token check runs after the item count, the one-operation check and the enum members read during deserialization, and ahead of each item's own checks. It also says that DynamoDB checks the token ahead of all three and lists it with a count fault in one message. main answers these rows as this PR does, so I filed the order as #1463.
Nothing pinned the call to `stored_token` in `transact_write_items`. With the call replaced by the token as sent, every engine test passed. On PostgreSQL that change answers 500 to a token that holds U+0000, because a text column holds no U+0000. `tests/test_idempotency_account_scope.py` now runs one test over a table of tokens: a plain one, one of U+0000, one of U+0000 after astral characters, one of backslashes, and one with a U+0000 inside, on a table of its own each. Each token applies once, replays with 200 and no second write, and answers IdempotentParameterMismatchException for a changed request. The plain row replaces the two single-token tests, whose steps the table test runs. A second test sends `x` U+0000 `y` and `x` `\` `0` `y` with one suffix and expects two transactions, because the two tokens must not share a stored form. The CI jobs run the file on every backend. With `stored_token` replaced, the tests that send U+0000 fail on PostgreSQL with InternalServerError. The plain and backslash rows pass, since a text column holds a backslash as sent. The design doc's section on the token table and the storage manual now say that the `token` of `IdempotencyKey` is that stored form. The comment in `transact_write_items` now says where the token check runs: after the item count, the one-operation check and the enum members read during deserialization, and ahead of each item's own checks. DynamoDB checks it ahead of all three.
#1009 compiles the engine's `partiql` module only with the `partiql` feature, and the WebAssembly adapter builds the engine without it. The TransactWriteItems token check read `length_constraint` and `MAX_CLIENT_REQUEST_TOKEN` from `partiql::request_checks`, so after the merge of main the engine did not compile without the feature: `cargo test -p extenddb-wasm-adapter` failed with E0433 at `transact_write_helpers.rs`. The two items and the `AT_LEAST_ONE` constraint they use move to `request_limits.rs`, which every build compiles. The PartiQL request checks import them from there. The code does not change.
hitesh96db
left a comment
There was a problem hiding this comment.
The item I required is fixed, and I have no open request. One optional cleanup remains. Checked at b0f1135c on SQLite, PostgreSQL and DynamoDB in us-east-1.
stored_token is now pinned. tests/test_idempotency_account_scope.py fails on PostgreSQL with the call changed to str::to_owned: 4 failed and 5 passed. The failures are [nul-run], [astral-and-nul], [nul-inside] and test_nul_and_backslash_zero_are_two_tokens, each answering InternalServerError with SQLSTATE 22021 in the server log. On SQLite all 9 pass with the call removed, so only PostgreSQL catches it, and run-integration (3) runs the file on PostgreSQL (9 of 9 pass). Dropping the NUL escape fails the same four tests. Dropping the backslash doubling, or swapping the two replaces, fails test_nul_and_backslash_zero_are_two_tokens on SQLite.
The token table passes on SQLite, PostgreSQL and DynamoDB, with two runs on DynamoDB. Four more tokens (36 U+0000, 36 U+1F600, 36 backslashes, 18 \0) pass on all three.
The new comment on the order of the token check matches the code and DynamoDB on every row I sent, each twice with identical answers. The commit that moved the length check out of the PartiQL module changes no answer: all 44 cells of the 22-token grid across TransactWriteItems and ExecuteTransaction are identical on SQLite, PostgreSQL, the earlier head and DynamoDB. The tightened Rust token assertion fails with the member-name case changed.
Optional: crates/engine/src/partiql/mod.rs line 55 still reads pub(crate) mod request_checks;, and nothing outside partiql uses it any more. Put it back to mod request_checks;.
One case my first review missed, optional: with TransactItems missing and a 37-character token, DynamoDB lists both faults and names the token member in lower case. ExtendDB answers a SerializationException. This belongs with #1463.
CI: 59 of 59 checks pass. The branch merges cleanly onto current main, and none of main's 13 newer commits touches the PR's files. The wider Python run on SQLite gave 361 passed and 2 xfailed.
Not measured: MongoDB and Cassandra, and a rerun of the PostgreSQL concurrent-send race.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194 and #1375, next to the existing entries for #398, #526 and #1166. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker.
* chore(release): bump version to 1.1.0 Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker. * docs(upgrade): add the v1.1.0 entry of #1290, put #1349's in order #1290 merged after this branch was rebased. It changes the answer to a request with no Authorization header, so it gets a v1.1.0 entry. The merge of main put the #1349 entry after the #1523 entry. It moves to the place of its number, beside the new #1290 entry. --------- Co-authored-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
Resolve the Cargo.toml and Cargo.lock merge conflicts with main (v1.1.0) and adapt the Cloud Bigtable storage backend to upstream changes: - Align workspace Cargo.toml and Cargo.lock with ExtendDB v1.1.0 (ExtendDB#1514), MSRV 1.94.0 and sqlx 0.9.1 (ExtendDB#1166), and extenddb-server default-features = false (ExtendDB#1449), bumping extenddb-storage-bigtable to =1.1.0. - Adapt AuthorizationStore::fetch_session_data (ExtendDB#1523) to look up role session policy, tags, and RFC 3339 created_at in O(1) by access_key_id via iam_session_ak:<access_key_id> -> iam_session:<session_token> without re-checking session expiry, with symmetric 4 KiB row-key and non-empty token guards across fetch_session_data and lookup_credential. - Decide StreamSpecification transitions in BigtableEngine::update_table ahead of companion table fields and GSI updates (ExtendDB#963) so a refused disable/enable writes no other table member while still closing any open shards left behind by a prior disable. - Update docs/bigtable-setup.md for Rust 1.94.0 and the exact v1.1.0 extenddb version output. - Add unit and live cbtemulator integration tests covering session_data_conformance::run, expired/deleted/oversized session-data and credential lookups, write_bootstrap_rows admin environment-variable combinations and idempotent re-runs (ExtendDB#1349), ClientRequestToken NUL/backslash/ UTF-8 escaped stored tokens (ExtendDB#1375), and refused stream disable/enable preceding companion edits (ExtendDB#963).
Merge upstream main (ExtendDB v1.1.0) into rfc/bigtable-backend and reverse-sync docs/rfcs/0000-bigtable-backend.md with the v1.1.0 trait surface and conformance coverage: - Update ExtendDB binary version literals to v1.1.0 (ExtendDB#1514). - Document O(1) access-key-indexed AuthorizationStore::fetch_session_data (including expired sessions), symmetric 4 KiB key-length bounds, and session_data_conformance::run (ExtendDB#1523). - Document escaped ClientRequestToken stored tokens (ExtendDB#1375), pre-companion StreamSpecification refusal in TableEngine::update_table (ExtendDB#963), default SettingsStore::get_setting_bounded (ExtendDB#1449), and write_bootstrap_rows admin environment-variable handling (ExtendDB#1349).
#1375 moved AT_LEAST_ONE, MAX_CLIENT_REQUEST_TOKEN and length_constraint from partiql/request_checks.rs to request_limits.rs. This branch moved MAX_PARTS there too. The merge imports those three and validation_refusal from request_limits.rs, and request_checks.rs keeps neither AT_LEAST_ONE nor MAX_PARTS.
NOT_NULL moves from partiql/request_checks.rs to request_limits.rs, beside AT_LEAST_ONE, as #1375 moved that constant. check_batch_get writes its null clause with it. The PartiQL module builds only with the partiql feature, and check_batch_get runs in every build, so the clause cannot come from Found::null.
Main is at db8a90d. This branch last had main at 3534c9e (#1009). Since then, 44 commits merged into main. Among them, #1514 released v1.1.0 without this branch, and #1166 moved to sqlx 0.9.1. Four files conflicted: - crates/storage/src/lib.rs: #1449 exports VectorItemFilter beside the transact exports that this branch extends. The merge keeps both. - crates/storage-mongodb/src/data_engine_live_tests.rs: #1446 declares its delete_table module where this branch declares token. The merge keeps both, main's first. - crates/storage-postgres/tests/twi_conflict.rs: #1166 passes the SQL of the deadlock test through sqlx::AssertSqlSafe, and this branch takes the outside transaction from outside_transaction. The merge keeps the helper and the wrapper. - docs/manuals/07-upgrade-manual.md: #1514 moved and rewrote the v1.1.0 ClientRequestToken entry of #526. This branch changed the Cassandra sentence of the old copy. The merge keeps the entry as main has it. The text of this branch is now a v1.2.0 entry after the v1.2.0 entries of main, because v1.1.0 shipped without this change. sqlx 0.9 takes SQL that is not a &'static str only in sqlx::AssertSqlSafe (#1166). The merge passes the SQL of the 11 queries that this branch adds to twi_conflict.rs in it. The SQL text does not change. Git merged these files, which both sides change, at other lines: - crates/core/src/error/mod.rs and crates/core/src/validation/mod.rs - crates/engine/src/transact_write_helpers.rs and crates/storage/src/transact.rs - tx_helpers.rs of PostgreSQL and SQLite, and crates/storage-postgres/src/data/update_item.rs - the Cassandra direct_integration.rs and docs/differences-from-dynamodb.md Since #1375, the engine stores a ClientRequestToken with each backslash doubled and each U+0000 written \0 before a backend sees it. The token code of this branch uses that stored form, as it used the token before.
What
TransactWriteItems now checks a
ClientRequestTokenas DynamoDB does. The check counts characters, 1 to 36, and has no pattern check. A refusal gets one of the two texts that DynamoDB gives:1 validation error detected: Value at 'ClientRequestToken' failed to satisfy constraint: Member must have length less than or equal to 361 validation error detected: Value at 'ClientRequestToken' failed to satisfy constraint: Member must have length greater than or equal to 1Before, the check counted bytes and refused a character outside
[a-zA-Z0-9-]with a pattern text. It answered an empty token with the maximum length text. Both texts named the memberclientRequestToken.The changes:
validate_client_request_tokenincrates/engine/src/transact_write_helpers.rschecks only the length and writes the two texts above.length_constraintincrates/engine/src/request_limits.rsholds the length rule. The ExecuteTransaction request checks had this rule inFound::length, with the limitMAX_CLIENT_REQUEST_TOKEN(36). Both checks now calllength_constraint, so the rule has one copy. The ExecuteTransaction texts do not change.stored_tokenintransact_write_helpers.rswrites each\as\\and each U+0000 as\0. The engine builds theIdempotencyKeyfrom this form, so no backend receives U+0000. The fingerprint still uses the token as sent.assert_token_refusedintests/rust/src/number_validation_order.rscompares the full text. Before, it ignored the case of the member name because of TransactWriteItems: the token length refusal names clientRequestToken, and DynamoDB now writes ClientRequestToken #959.tokenofIdempotencyKeyis this stored form.Fixes #959
Fixes #1374
Why
I measured DynamoDB in us-east-1 on 23 November 2026. Each TransactWriteItems request had one Put to a table that does not exist. Each request went out twice and got the same answer both times. A token that passes the check reaches the table lookup and gets
ResourceNotFoundException.aé(72 bytes)abc_def,abc defabc, then U+0001, a tab or U+0000, thendef\alone,\before0a, 37_, 36aand one_, 37éThe ExtendDB texts before named
clientRequestToken, so the T1, T5, T6 and T8 answers differ in the member name. The pattern text wasMember must satisfy regular expression pattern: [a-zA-Z0-9-]+. With this PR, ExtendDB gives the answer of DynamoDB for every row.I measured ExecuteTransaction on the same day. Eleven of the tokens went out as its
ClientRequestToken, with one INSERT into a table that does not exist, each twice. The same tokens pass. A refusal keeps the ExecuteTransaction form,1 validation error detected: Value '<token>' at 'clientRequestToken' failed to satisfy constraint: .... ExecuteTransaction gives its token to the TransactWriteItems check after its own length check. So before this PR, a token such asabc_defgot the pattern text there too.Each backend stores the token for idempotency. PostgreSQL stores it in a
textcolumn, which cannot hold U+0000, so a token with U+0000 would fail the statement. In the stored form, two tokens never get the same string, because the form decodes to one token only. A token of[a-zA-Z0-9-]is the only kind an earlier build accepted, and its stored form is the token. A replay after an upgrade therefore finds the token that an earlier build stored.The PostgreSQL catalog has its own U+0000 escape,
escape_strincrates/storage-postgres/src/catalog_json.rs, for its JSON documents. This PR does not reuse it in the PostgreSQL token query. The escape in the engine keeps U+0000 out of all four backends. Withescape_strin the PostgreSQL token query only, SQLite, MongoDB and Cassandra would store a token that holds U+0000. That path did not run on this host. That form would be about 10 lines shorter.Testing done
cargo test -p extenddb-engine --lib --no-fail-fast: 869 passed.cargo test -p extenddb-storage --no-fail-fast: 284 passed.cargo +1.97.0 clippy -p extenddb-engine -p extenddb-storage --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean.client_request_tokenshas the 15 measured rows with the answers of DynamoDB, and the stored form of each token. A control kept the tests and put back the check ofmain: 14 of the 15 rows failed.__typeincluded. The 11 ExecuteTransaction rows got the status, type and text of DynamoDB.\and a tab twice. The server answered the second request as a replay, with 2 read capacity units. The same token with another Put gotIdempotentParameterMismatchException. The tokensxU+0000yandx\0ywrote two items.[a-zA-Z0-9-]with a build ofmain. A build of this PR then served the same SQLite file. The same request was a replay, and the same token with another Put gotIdempotentParameterMismatchException.TRANSACTION_INDEX_UNITSmarks, which do not depend on the token.Over main after the merge, production is +66 -53, the docs +7 -1 and the tests +83 -46.
git merge-treeof b0f1135 with main at a417b2f is clean. With four open PRs, b0f1135 adds a conflict incrates/engine/src/partiql/request_checks.rs. #1262, #1365, #1367 and #1373 deleteNOT_NULLnext to theAT_LEAST_ONElines that this PR moves. A resolution deletes both.Changes since the 24 November review
tests/test_idempotency_account_scope.py. One test runs over a table of five tokens: a plain token, 28 U+0000, 14 U+1F600 and 14 U+0000, 20 backslashes, andxU+0000y. Each one runs on a table of its own. Each token applies once, replays with no second write, and refuses a changed request. The plain row replaces the two single-token tests. A second test sendsxU+0000yandx\0yand expects two transactions. The commit also narrows the token comment intransact_write_itemsand describes the stored form in the design doc and the storage manual.length_constraint,MAX_CLIENT_REQUEST_TOKENandAT_LEAST_ONEtocrates/engine/src/request_limits.rs. After the merge, the engine did not compile without itspartiqlfeature, which the WebAssembly adapter leaves off.cargo test -p extenddb-engine --libpassed 888 tests, andcargo test -p extenddb-wasm-adapterpassed its 3 unit tests and the parity corpus.cargo check -p extenddb-engine --no-default-features --lib, clippy with-D warningson the engine, andcargo fmt --checkare clean.stored_tokenreplaced by the token as sent, the engine lib tests still passed. On PostgreSQL the four tests that send U+0000 then failed with InternalServerError, and the plain and backslash rows passed.DynamoDB checks the token ahead of the item count, the one-operation check and the enum members. ExtendDB checks it after them, on main and on this branch. #1463 tracks that order.
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
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.