Repository navigation
fix(server): send Message on a SerializationException - #1220
LeeroyHannigan wants to merge 13 commits into
Conversation
error_response wrote every error message under a lower-case message key. Amazon DynamoDB sends Message on TransactionCanceledException and IdempotentParameterMismatchException, and message on every other error measured. botocore reads either key, but a client that reads the modeled Message member of those two errors from the raw body found nothing. The key now comes from message_key, which picks Message for those two errors and message for every other one. TransactionInProgressException also models its member as Message; it was not measured and ExtendDB does not raise it, so it keeps message. REQ-ERR-002 and the doc comment of error_response name the key. A unit test, in response_tests.rs, checks the top-level keys of the body error_response sends for both errors and for three others. tests/test_error_message_key.py reads the raw body from botocore's before-parse event for a cancelled transaction, an idempotency token reused with different parameters, a failed condition and a validation error. It passes against Amazon DynamoDB in us-east-1 and against this change; against a build of main the two Message tests fail. The token mismatch text, which #760 also reports, is left to #526. Part of #760.
Main now ends crates/server/src/response.rs with its own `#[cfg(test)] mod tests` (#922). With this branch's `mod tests` beside it, `cargo check --tests -p extenddb-server` fails with E0428 on the merged tree. The module that loads response_tests.rs is now `message_key_tests`.
The service sends `Message` on more errors than the two this branch changes. In us-east-1 on 19 November 2026, with each request sent twice, these raw bodies also carried `Message`: - TransactionInProgressException: eight concurrent TransactWriteItems with one token. - AccessDeniedException: DescribeTable with a table ARN of another account. - SerializationException: DescribeTable with TableName 5. Twelve other errors carried `message`, among them ConditionalCheckFailedException, ValidationException, ResourceNotFoundException and TransactionConflictException. REQ-ERR-002, the comment on `message_key` and the docstring of tests/test_error_message_key.py now name the errors measured with each key. ExtendDB still sends `message` on AccessDeniedException and SerializationException. Nothing in ExtendDB raises TransactionInProgressException.
ExtendDB wrote the text of a SerializationException under the key
`message`. Amazon DynamoDB sends it under `Message`. A client that
reads the member named `Message` from the raw body found no text.
DynamoDB in us-east-1 refused a member of the wrong JSON type with the
text under `Message` on each of these requests:
- 18 November 2026: ExecuteStatement with a Limit of `{}`, `true` or
`"2"`, each sent twice, and with a parameter of `{"S": 5}`.
- 20 November 2026, each sent twice: Query with a Limit of `"0"`,
GetItem with a ConsistentRead of `"x"`, PutItem with a ReturnValues
of 5, and ExecuteStatement with a Limit of `"2"`.
A refusal with no text carries neither key, as before. DynamoDB sent no
text for an ExecuteStatement Limit of `[1]` and for a BatchWriteItem
RequestItems value of `"x"`.
`message_key` now picks `Message` for SerializationException as well.
Fixes #1143.
Main's #1009 moved the error body and `message_key` from `crates/server/src/response.rs` to `extenddb_core::error::error_document` in `crates/core/src/error/mod.rs`. The merge takes main's `response.rs`, and core's `message_key` now picks `Message` for `SerializationException`, with this branch's comment. The server test of the key reads the body `error_response` sends, which `error_document` builds.
The WebAssembly parity corpus that #1009 added records ExtendDB's answers, and 15 of its cases check the text of a SerializationException at `/message`. This branch sends that text under `Message`, as DynamoDB does, so those checks now read `/Message`. Each case keeps its expected text.
test_serialization_error_carries_message_under_capital_m now checks that each of its four requests gets HTTP status 400. DynamoDB answered each of them with 400 in us-east-1 on 25 Nov 2026. Each request was sent twice. _error_code_and_keys returns the status as a third value, and the other tests do not read it. The test does not check the message texts, because ExtendDB's texts differ from DynamoDB's (#1012, #884).
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 5f4f03b. Core, server and wasm-adapter unit and parity tests pass, and tests/test_error_message_key.py passes 8 of 8 on PostgreSQL (4 fail with main's message_key). Remaining note is about recording the wire change in the upgrade manual.
Docs — outside the diff
docs/manuals/07-upgrade-manual.md:385— Please add an entry under Behavior Changes by Release for the move of theSerializationExceptiontext frommessagetoMessage, which the PR body lists as a breaking change. With main'smessage_key, the new test in tests/test_error_message_key.py fails 4 of 4 cases with keys['__type', 'message'], and at this head it passes. If the project does not record error-body key changes there, since the earlierMessagechange for TransactionCanceledException has no entry either, this note can be dropped.
Behavior Changes by Release gets a v1.2.0 entry for this change. A SerializationException carries its text under Message, the key DynamoDB sends for it, where 1.1.0 sent message. A client that reads message from the raw body of a SerializationException finds the text under Message.
|
LJMart11
left a comment
There was a problem hiding this comment.
Checked at 4f3e0f2 against the list from 5f4f03b.
The follow-up merges main and adds the v1.2.0 entry for the SerializationException key change to the upgrade manual. The entry exists at docs/manuals/07-upgrade-manual.md:413-417 and its anchor link matches the v1.1.0 heading. tests/test_error_message_key.py passes 8 of 8 on PostgreSQL. Removing SerializationException from message_key fails the_message_key_follows_the_service_per_error (left ["__type", "message"], right ["Message", "__type"]). Core (1260), server lib (526) and wasm-adapter tests pass under 1.94.0.
Previous items: 1 fixed.
navareamol
left a comment
There was a problem hiding this comment.
I think the change is also applied to DynamoDB Streams, and the description only measures DynamoDB operations. On a build of this head, DescribeStream with a StreamArn of 5 and ListStreams with a Limit of "x" send the text under Message, and five Streams cases of the parity corpus (GetRecords with no ShardIterator, a number, null, an array body and an iterator that does not parse) were changed from /message to /Message. Has anyone measured the raw body of a SerializationException from the Streams endpoint? If it also sends Message, can the description say so with the date? If not, can the change be limited to the DynamoDB service?
For the three requests where DynamoDB sends no text, ExtendDB still sends the parser's text, now under Message. The new wire test only covers four requests that have a text on DynamoDB. Is the key for one of the no-text requests pinned by a test, or is that left to the work on those texts?
I will approve once the Streams key is measured or limited.
Main is at 5826e1b. This branch last had main at c8e66fb. Since then, four PRs merged into main: #1446, #1531, #1466 and #1087. One file conflicted. In docs/manuals/07-upgrade-manual.md, #1087 added its v1.2.0 entry after the other v1.2.0 entries of main, where this branch has its entry. The merge keeps the entries of main first, then the entry of this branch. Git merged crates/wasm-adapter/parity/corpus.json with no conflict: #1087 adds a Scan case, and the 15 checks that this branch changes are in other cases. The diff of this branch against main does not change in that file.
…rder The branch of #1220 is at 57c4d7a, which merges main at 5826e1b. This branch last had it at 4f3e0f2, with main at c8e66fb. Git merged docs/manuals/07-upgrade-manual.md with no conflict. #1087 added its v1.2.0 entry after the other v1.2.0 entries of main. The entry of #1220 and the entry of this branch follow it, in that order. No other file that this branch changes moved.
|
|
Checked at Fixed:
Disputed: none. Needs-human: none. |
Changes since the last review
docs/manuals/07-upgrade-manual.md, fix(storage-sqlite): keep each partition key in one parallel Scan segment #1087 added its v1.2.0 entry where this PR has its entry. The merge keeps the entries of main first. Git mergedcrates/wasm-adapter/parity/corpus.jsonwith no conflict, and the diff of this PR against main does not change.SerializationExceptionunderMessagetoo, so the change applies there as it is.What
ExtendDB wrote the text of a
SerializationExceptionunder the keymessage. DynamoDB sends it underMessage.message_keynow picksMessageforSerializationExceptiontoo. #774 added that function incrates/server/src/response.rs, and #1009 moved it tocrates/core/src/error/mod.rs, whereerror_documentbuilds the error body for the server and for the WebAssembly build. The change applies to every operation, the DynamoDB Streams operations included, and to a body that fails the JSON read before an operation runs. A refusal with no text carries neither key, as before.docs/manuals/07-upgrade-manual.mdlists the change in a v1.2.0 entry.The base of this PR is main. #774 and #1009 are on main.
Why
DynamoDB's answers, measured in us-east-1 on 18 and 20 November 2026. Each request was sent twice and got the same body both times. The requests of 20 November name a table that does not exist, and DynamoDB refused each type fault before the table lookup.
"Limit": "0"Message:STRING_VALUE cannot be converted to Integer"ConsistentRead": "x"Message:Unexpected token received from parser"ReturnValues": 5Message:NUMBER_VALUE cannot be converted to String{"S": 5}Message:NUMBER_VALUE cannot be converted to String"Limit"of{},trueor"2"Message, with a text for each"Limit": [1]RequestItemsvalue of"x"}The Streams endpoint of us-east-1 (
streams.dynamodb.us-east-1.amazonaws.com) gave the same key on 4 December 2026. Each request was a raw signed request, sent twice, and got the same body both times. The stream ARN names a table that does not exist."StreamArn": 5Message:NUMBER_VALUE cannot be converted to String"Limit": "x"Message:STRING_VALUE cannot be converted to Integer"Limit": "x", with and without aTableNameMessage:STRING_VALUE cannot be converted to Integer"ShardIterator": 5Message:NUMBER_VALUE cannot be converted to String}On the same day, the Query with
"Limit": "0"gotMessageagain from the DynamoDB endpoint.Each refusal is HTTP 400
SerializationException. Before this change, ExtendDB sent the text of eachSerializationExceptionundermessage.Fixes #1143
Testing done
At 57c4d7a:
cargo +1.97.0 test -p extenddb-core --lib: 1260 passed, 1 ignored.cargo +1.97.0 test -p extenddb-server --lib: 521 passed, and 5backup_store::testsfailed. They fail on this host on every branch, because uid 65534 owns/local/home, an ancestor of the directories the tests make.-D warningsonextenddb-core,extenddb-serverandextenddb-wasm-adapter, with the test hooks of.github/workflows/clippy.yml, is clean. So are the clippy step of.github/workflows/wasm.yml,cargo +1.94.0 check --all-targetson the three crates, andcargo +1.97.0 fmt --all -- --check.cargo test -p extenddb-storage-postgres --test doc_version_literalspasses with the new entry.the_message_key_follows_the_service_per_errorgets two asserts: aSerializationExceptionwith a text, and one with no text.tests/test_error_message_key.pypassed 8 tests against ExtendDB on SQLite, and 8 on PostgreSQL. Its new test sends the first four requests of the first table and checks the key of the text and the HTTP status. At 5f4f03b, those four rows failed against a server built with main'scrates/core/src/error/mod.rs, and this PR's change to that file is the same at 57c4d7a.SerializationExceptiongave 859 passed and 2 expected failures on SQLite. The other 9 tests, all intests/test_streams_at_timestamp.py, failed in the client, which sent no request. This host's botocore 1.43.92 has noTimestampmember in its model of GetShardIterator.StreamArnof 5, and ListStreams with aLimitof"x"with and without aTableName, send the text underMessage.crates/wasm-adapter/parity/corpus.json, from feat(wasm): [Add WebAssembly browser support for ExtendDB #1009) from/messageto/Message, because those cases read the text of aSerializationException.cargo test -p extenddb-wasm-adapterpasses: 3 unit tests and the parity corpus.python3 -m pytest --collect-only -qcollectstests/andtests/pythonwith no error.Line counts: production +9 -9, tests +65 -9, 15 changed lines of the parity corpus, and 6 added lines of the upgrade manual.
This PR holds five merges of main. The merge of 3534c9e (35487cb) takes main's
response.rsand makes this PR's change in core'smessage_key. The merges of a417b2f (e1f159a), c8e66fb (aff886f) and 5826e1b (57c4d7a) change none of the lines of this PR.Not in this PR:
Messagenow comes before__type. A build with the MongoDB backend keeps__typefirst, because bson enables serde_json'spreserve_order. DynamoDB writes__typefirst (An error body lists its members in name order, so CancellationReasons comes before __type, where DynamoDB writes __type first #1222, open PR fix(server): write __type first in an error body #1249). A reader that looks up members by name gets the same values.Keyand PutItem withoutItemget aSerializationExceptionfrom ExtendDB, where DynamoDB answers aValidationException(GetItem without Key and PutItem without Item answer SerializationException with serde_json's text, where DynamoDB answers ValidationException at the member path #1219, open PR fix(engine): answer a missing TableName, Key or Item as DynamoDB does #1262). With this change, the ExtendDB text of these two requests moves toMessage."Limit": 1e400fails the JSON read in ExtendDB, where DynamoDB reads the number (A Limit number is read through a double: a decimal close to an integer reads as that integer, and a number beyond the double range fails the request parse, where DynamoDB reads the digits as written #1203).ShardIteratorof 5 getsValidationExceptionInvalid ShardIteratorfrom the server, which reads the iterator before the body. DynamoDB Streams answers theSerializationExceptionof the table above (GetRecords with a ShardIterator of another JSON type answers ValidationException, where DynamoDB Streams answers SerializationException #1578).This PR adds a conflict with these open PRs:
crates/server/src/response_tests.rsandcrates/core/src/error/mod.rs. In the test, both reword the comment ofthe_message_key_follows_the_service_per_error, and both add an assert after theIdempotentParameterMismatchExceptionassert. Inmessage_key, both add an arm and rewrite its comment. On a rebase, keep both arms and the asserts of both, and drop "which ExtendDB does not raise" forTransactionInProgressExceptiononce fix(transact): rank index-key faults and handle the ClientRequestToken as the service does #853's arm is in.crates/wasm-adapter/parity/corpus.json, on the case of GetItem with noKey. fix(engine): answer a missing TableName, Key or Item as DynamoDB does #1262 changes that case to the ValidationException of a missing member, whose text stays undermessage. On a rebase, keep fix(engine): answer a missing TableName, Key or Item as DynamoDB does #1262's case.docs/manuals/07-upgrade-manual.md, fix(core): refuse a name that starts with an underscore in an expression #1131 among them. On a rebase, keep both entries.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
A
SerializationExceptioncarries its text underMessage, where earlier releases wrotemessage. botocore reads either key. A client that reads the raw body undermessageno longer finds the text. The answers of the WebAssembly build change the same way.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.