Skip to content

fix(server): send Message on a SerializationException - #1220

Open
LeeroyHannigan wants to merge 13 commits into
mainfrom
fix/1143-serialization-message-key
Open

LeeroyHannigan wants to merge 13 commits into
mainfrom
fix/1143-serialization-message-key

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

  • 57c4d7a merges main at 5826e1b. One file conflicted. In 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 merged crates/wasm-adapter/parity/corpus.json with no conflict, and the diff of this PR against main does not change.
  • Why now has the raw bodies that the DynamoDB Streams endpoint sent on 4 December 2026. Streams sends the text of a SerializationException under Message too, so the change applies there as it is.
  • This body now gives the results and the conflicts at 57c4d7a.

What

ExtendDB wrote the text of a SerializationException under the key message. DynamoDB sends it under Message. message_key now picks Message for SerializationException too. #774 added that function in crates/server/src/response.rs, and #1009 moved it to crates/core/src/error/mod.rs, where error_document builds 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.md lists 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.

Request DynamoDB
Query, "Limit": "0" Message: STRING_VALUE cannot be converted to Integer
GetItem, "ConsistentRead": "x" Message: Unexpected token received from parser
PutItem, "ReturnValues": 5 Message: NUMBER_VALUE cannot be converted to String
ExecuteStatement, a parameter of {"S": 5} Message: NUMBER_VALUE cannot be converted to String
ExecuteStatement, "Limit" of {}, true or "2" Message, with a text for each
ExecuteStatement, "Limit": [1] no text
BatchWriteItem, a RequestItems value of "x" no text
Query, a body that ends before its last } no text

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.

Request DynamoDB Streams
DescribeStream, "StreamArn": 5 Message: NUMBER_VALUE cannot be converted to String
DescribeStream, "Limit": "x" Message: STRING_VALUE cannot be converted to Integer
ListStreams, "Limit": "x", with and without a TableName Message: STRING_VALUE cannot be converted to Integer
GetRecords, "ShardIterator": 5 Message: NUMBER_VALUE cannot be converted to String
DescribeStream, a body that ends before its last } no text

On the same day, the Query with "Limit": "0" got Message again from the DynamoDB endpoint.

Each refusal is HTTP 400 SerializationException. Before this change, ExtendDB sent the text of each SerializationException under message.

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 5 backup_store::tests failed. They fail on this host on every branch, because uid 65534 owns /local/home, an ancestor of the directories the tests make.
  • Clippy with -D warnings on extenddb-core, extenddb-server and extenddb-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-targets on the three crates, and cargo +1.97.0 fmt --all -- --check.
  • cargo test -p extenddb-storage-postgres --test doc_version_literals passes with the new entry.
  • The unit test the_message_key_follows_the_service_per_error gets two asserts: a SerializationException with a text, and one with no text.
  • tests/test_error_message_key.py passed 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's crates/core/src/error/mod.rs, and this PR's change to that file is the same at 57c4d7a.
  • Seven other wire files that check a SerializationException gave 859 passed and 2 expected failures on SQLite. The other 9 tests, all in tests/test_streams_at_timestamp.py, failed in the client, which sent no request. This host's botocore 1.43.92 has no Timestamp member in its model of GetShardIterator.
  • On a SQLite server, DescribeStream with a StreamArn of 5, and ListStreams with a Limit of "x" with and without a TableName, send the text under Message.
  • b5f7ced moves 15 checks of the WebAssembly parity corpus (crates/wasm-adapter/parity/corpus.json, from feat(wasm): [Add WebAssembly browser support for ExtendDB #1009) from /message to /Message, because those cases read the text of a SerializationException. cargo test -p extenddb-wasm-adapter passes: 3 unit tests and the parity corpus.
  • python3 -m pytest --collect-only -q collects tests/ and tests/python with 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.rs and makes this PR's change in core's message_key. The merges of a417b2f (e1f159a), c8e66fb (aff886f) and 5826e1b (57c4d7a) change none of the lines of this PR.

Not in this PR:

This PR adds a conflict with these open PRs:

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

A SerializationException carries its text under Message, where earlier releases wrote message. botocore reads either key. A client that reads the raw body under message no 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.

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 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. docs/manuals/07-upgrade-manual.md:385 — Please add an entry under Behavior Changes by Release for the move of the SerializationException text from message to Message, which the PR body lists as a breaking change. With main's message_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 earlier Message change 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.
@navareamol navareamol self-assigned this Dec 3, 2026
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@LJMart11

  1. 4f3e0f2 adds a v1.2.0 entry under Behavior Changes by Release in docs/manuals/07-upgrade-manual.md, "a SerializationException carries its message under Message". It sits after main's two v1.2.0 entries. It gives the move from message to Message, with the dates of the measurement. It also names the answers of the WebAssembly build and the client that reads message from the raw body. The earlier Message change for TransactionCanceledException and IdempotentParameterMismatchException (fix(server): send Message on the two errors the service sends it on #774) has an entry too. It is the third bullet of the v1.1.0 entry on expression characters, Scan values and two error bodies. The new entry links to it. Before that commit, aff886f merges main at c8e66fb, with no conflict. At 4f3e0f2, tests/test_error_message_key.py passes 8 of 8 against SQLite, and so does the doc_version_literals test.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 navareamol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the 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.
LeeroyHannigan added a commit that referenced this pull request Dec 4, 2026
…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.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. I measured it on the Streams endpoint of us-east-1 on 4 Dec, with raw signed requests, each one twice. Each of these got HTTP 400 com.amazon.coral.service#SerializationException with the text under Message:

    • DescribeStream with a StreamArn of 5: NUMBER_VALUE cannot be converted to String
    • DescribeStream with a Limit of "x", on a stream ARN that does not exist: STRING_VALUE cannot be converted to Integer
    • ListStreams with a Limit of "x", with and without a TableName: STRING_VALUE cannot be converted to Integer
    • GetRecords with a ShardIterator of 5: NUMBER_VALUE cannot be converted to String

    A DescribeStream body that ends before its last } got __type alone. So the change holds for Streams too, and the description now says so with the date. On a SQLite server built from 57c4d7a, DescribeStream with a StreamArn of 5 and ListStreams with a Limit of "x" send the text under Message. GetRecords with a ShardIterator of 5 gets ValidationException Invalid ShardIterator from the server, because it reads the iterator before the body. That is in code this PR doesn't change, and GetRecords with a ShardIterator of another JSON type answers ValidationException, where DynamoDB Streams answers SerializationException #1578 tracks it.

  2. No test pins the key for the three requests where DynamoDB sends no text. A row of the wire test runs against DynamoDB too, and there DynamoDB sends __type alone, so a row can't assert a key. ExtendDB sends serde_json's text there, now under Message. The parity corpus checks /Message on ExtendDB's text for a body that isn't JSON (Malformed body on a known operation is SerializationException), where DynamoDB sends no text (ExtendDB adds a message to the SerializationException for a body with a JSON syntax fault, where the service sends none #1195). A request member of the wrong JSON type gets serde_json's error text, where the service sends its own #1012 and ExtendDB adds a message to the SerializationException for a body with a JSON syntax fault, where the service sends none #1195 track whether ExtendDB sends a text in these cases.

@LJMart11

LJMart11 commented Dec 4, 2026

Copy link
Copy Markdown

Checked at 4f3e0f2 against the list from 5f4f03b. The head moved again to 57c4d7a; this reviewer stops after two rounds and leaves the rest to a person.

Fixed:

  • item 1

Disputed: none.

Needs-human: none.

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.

SerializationException carries its text under message, where DynamoDB sends Message

3 participants