Skip to content

fix(server): send no message for a body with a JSON syntax fault - #1261

Open
LeeroyHannigan wants to merge 8 commits into
fix/request-nesting-depthfrom
fix/1195-syntax-fault-message
Open

LeeroyHannigan wants to merge 8 commits into
fix/request-nesting-depthfrom
fix/1195-syntax-fault-message

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

For a request body with a JSON syntax fault, ExtendDB now sends HTTP 400 and {"__type":"com.amazon.coral.service#SerializationException"} with no message, as DynamoDB does. Before this change, the body also had a message. It was "Start of structure or map found where not expected: " and the JSON parser's error text.

The change is in crates/server/src/request_parse.rs:

  • over_ceiling_refusal is now serialization_refusal. It already wrote the body with no message for a body nested past the depth ceiling.
  • parse_request_value and check_request_syntax send each syntax fault to serialization_refusal.
  • check_request_syntax has no depth parameter now. The parameter only chose between the two refusals.
  • This PR deletes serialization_error, which wrote the old message.

The README describes how the WebAssembly build refuses the PartiQL operations. Its item now says that a server answers a body that does not parse with no message. That build parses a body with serde_json's defaults, so it still sends the message (#1471).

REQ-ERR-002 in docs/design/01-requirements.md now says that the SerializationException for a syntax fault or for a body past the depth ceiling has no message field.

parse_request_value also sends bytes after a complete JSON value to the same refusal. DynamoDB reads such a body (#1008), so no test checks this answer.

The base of this PR is #807, which adds check_request_syntax and the depth ceiling.

Why

DynamoDB's answers, measured in us-east-1 on 20 November 2026. Each body went to DescribeTable or PutItem for a table that does not exist, signed, at least twice:

  • an empty body
  • a body of white space only
  • {not json
  • a byte order mark before the object
  • a trailing comma in the object
  • NaN as a number
  • tru as a value
  • a raw control byte in a string
  • x and then 200 [
  • x and then 6000 [
  • a PutItem body of 10 nested maps without its last byte
  • the same body with ] for its last }
  • a PutItem body of 200 nested maps without its last byte
  • an item string with the escape \q
  • an item string with a raw control byte

Each send got HTTP 400 and {"__type":"com.amazon.coral.service#SerializationException"}, with no message field. On 19 November, unsigned sends of bodies cut short and of bodies with a bad literal got the same answer.

ExtendDB on #807 gave DynamoDB's answer for one of these 15 bodies: x and then 6000 [, which is past its ceiling of 5200 levels. For the other 14 it sent the message. With this change, it gives DynamoDB's answer for all 15.

Fixes #1195

Testing done

Line counts of this PR's own change at 600726b: production +21 -34, tests +142 -94, README +4 -5 and the requirements doc +1 -1.

With main at c057660 and at 5826e1b (3 December 2026), git merge-tree of this head reports conflicts in README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs. #807 at 71b3e1b has the same three conflicts, in files that #807 changes. Of the three, this PR changes only README.md. Its sentence on the PartiQL operations of the WebAssembly build is inside the conflict hunk, because #1521 on main moved that section to docs/webassembly.md. There the sentence still has the old message, in the PartiQL item (lines 166 to 174 at 5826e1b). This branch takes main through #807, so the merge of main starts at #807. When this branch then merges #807's new head, this PR's change to the sentence goes into that item of docs/webassembly.md.

This PR adds a conflict with the open PR #530 in README.md. #530 changes the first line of the DescribeEndpoints item in the WebAssembly section, which comes right after the lines this PR changes. #537 sits on #530's branch and contains #530's head 469669e, so its head gets the same conflict. #537's own change leaves README.md as it is. Each other open PR that conflicts with this PR has the same conflicting files with #807. #200, #547, #549, #557, #587, #850 and #854 conflict with #807 and with this PR in crates/server/src/handler.rs. For #200, #850 and #854, the hunks are the same, and the changed check_request_syntax call is in none of them. For #547, #549, #557 and #587, one hunk holds the handler's body checks on #807 too, and the changed call is inside it.

Not in this PR, each in an open issue:

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 request whose body does not parse as JSON still gets HTTP 400 and a SerializationException. The error now has no message field. Before this change, it had the message "Start of structure or map found where not expected: " and the JSON parser's error text.


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.

For a signed request body with a JSON syntax fault, DynamoDB sends
HTTP 400 and {"__type":"com.amazon.coral.service#SerializationException"}
alone. ExtendDB sent that type with the message "Start of structure or
map found where not expected: " and the JSON parser's error text.

Measured in us-east-1 on 2026-11-20, with each body sent signed at
least twice. Some bodies were empty, white space only or cut short.
Others held a byte order mark, a bad literal or escape, a trailing
comma, NaN or a raw control byte. No answer had a message field.
Unsigned, bodies cut short and bodies with a bad literal got the same
answer on 2026-11-19.

ExtendDB now answers such a body as it answers a body nested past its
depth ceiling: a SerializationException with no message. This also
drops the message for bodies that #1008, #1196 and #1257 track.

Fixes #1195.
Merges 4c2995c of fix/request-nesting-depth. That is its four commits
since 1f49125 and its two merges of main (44cd436 and 6aef346).
The four commits are the syntax scan with the service's grammar in
request_syntax.rs, the message boundary test, the manual paragraph and
the module split.

Conflicts and their resolution:

- crates/server/src/request_parse.rs, check_request_syntax: the other
  branch calls request_syntax::skip_value and keeps the depth branch
  that picks the message. This branch has one argument and no message
  for any refusal. Kept: one argument, skip_value, and every error
  mapped to serialization_refusal. The depth branch, over_ceiling_refusal
  and serialization_error go. The doc comment keeps the other branch's
  grammar and measurements and this branch's message sentence.
- crates/server/src/request_parse.rs, the refusal test: this branch
  renamed it a_body_with_a_syntax_fault_is_refused_with_no_message with
  (body, read) rows that run the parse and the check. The other branch
  added seven leaf faults and two rows of exactly 5200 and 5201 openers
  that pin where the message stopped. Kept: this branch's shape, with
  the seven leaf faults as rows that are not read. The two boundary rows
  go: no refusal has a message now.
- tests/test_request_nesting_depth.py, the refusal test: the other
  branch added the leaf parameter and seven rows. This branch replaced
  the message check with _is_messageless_serialization_error. Kept:
  both, and one comment that names the dates and the missing message.

Auto-merged: handler.rs (the one-argument call beside main's
point-in-time recovery refusal), the pass test's one-argument call, and
the files of main.
Merges b9baaf5 of fix/request-nesting-depth. That commit merges main
at 018715e into the other branch, five commits past 6aef346:

- #503: the stream retention cutoff shape on SQLite
- #526: the Return fields on a TransactWriteItems token replay
- #690: catalog-check matches data relations by catalog id
- #765: the FilterExpression suffix in the values message
- #774: the Message key on two errors

No conflicts. None of the five changes a file of this branch. #774
changes crates/server/src/response.rs, which renders the refusals that
this branch's tests assert. SerializationException keeps the message
key, and a refusal with an empty message still has no message key.
Merges 1a9efd7 of fix/request-nesting-depth. That brings its merge of
main at b0d1c64 (#1280, #1009 and #596). It also brings the commit
that makes the handler call extenddb_engine::check_operation before its
body checks, and with_body(input).admit() after authentication.

No conflicts. crates/server/src/handler.rs auto-merged. The two hunks of
the other branch are the name check and the point-in-time refusal. This
branch's one-argument check_request_syntax call sits between them.
request_parse.rs and the two test files are as on this branch.

One edit to the merge result is in README.md. #1009's item on the
PartiQL operations gives a server's answer to a body that does not
parse. That answer has the message "Start of structure or map found
where not expected: …". This branch answers such a body with no
message, so the item now says that.
Merges 027483d of fix/request-nesting-depth. That commit changes one
sentence of the WebAssembly adapter's module doc in
crates/wasm-adapter/src/runtime.rs.

No conflicts. The commit changes no file of this branch.
_is_messageless_serialization_error in tests/test_request_nesting_depth.py
checked the type and that the error had no "message" key. A refusal with
its message under "Message" passed it. The helper now compares the whole
error document with {"__type": SERIALIZATION_TYPE}, as
tests/test_syntax_fault_message.py does.

On the server, each refusal that the helper checks is that document
alone. The service answered each malformed deep body with that document
alone, unsigned and badly signed.
REQ-ERR-002 in docs/design/01-requirements.md said that an error must
have a message field, and it listed SerializationException among the
errors that carry "Message". The server now sends a SerializationException
with no message field for a body that does not parse as JSON, as the
service does. The depth ceiling's refusal has no message field either.
REQ-ERR-002 now says so.
Merges 71b3e1b of fix/request-nesting-depth, the rows at the edges of
the syntax check's looser rules. At 63 and at 20000 wrappers, the
numbers 1+, 1e+5 and 1.eE-+ and the escape \ugggg reach authentication.
The numbers +1 and .5 and the escapes \u000/ and \u000h get a refusal
before it.

Two conflicts, both in the refusal tests:

- crates/server/src/request_parse.rs: this branch replaced the other
  branch's refusal test with a_body_with_a_syntax_fault_is_refused_with_no_message.
  The eight refused rows go into its table as rows the server does not
  read. The parse and the check must each refuse them with no message.
  Its comment names them with their measurement.
- tests/test_request_nesting_depth.py: the comment of
  test_a_malformed_deep_body_is_refused_before_authentication keeps this
  branch's words "and no message field" and takes the other branch's
  dates for the eight new rows. This branch's assertion, a
  SerializationException with no message field, applies to each of them.

The four new leaves of LOOSE_LEAVES auto-merged in both files.

@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 found no defect in the change itself. Two items on the PR:

  1. This head does not merge with current main. git merge-tree of the head with main (222d80a) reports one conflict, in crates/engine/src/lib.rs, a file this PR does not change. The conflict is between the base branch and main: the base branch changes the pub use pre_dispatch::{...} line and main added #[cfg(test)] mod test_context; just above it. I kept both lines, built the merged tree and ran tests/test_syntax_fault_message.py and tests/test_request_nesting_depth.py on SQLite: 120 passed. CI ran on the head, not on that merged tree. I think the base branch needs to be updated with main first, then this branch. Is that planned?

  2. The checklist and the Testing done section disagree. The checklist ticks "All tests pass (cargo test --workspace)". Testing done gives cargo test -p extenddb-server --lib at e7ef4ad (506 passed, 5 failing on that host), and no workspace run for any later commit. The bullet for 600726b lists fmt, clippy, the 11 request_parse tests and the two Python files. I think either the box should be unticked, or the section should name a workspace run at the current head. I ran the 11 request_parse tests at the head and they pass.

What I ran, so you can skip it: with serialization_refusal changed back to return the old message, 3 of the 11 unit tests fail (the new test fails at the empty body) and 54 of the 120 Python tests fail. A build of the base branch fails 41 of the 120 (13 of the 15 new rows plus 28 nesting rows), so the new rows do detect this change. Bodies with invalid UTF-8, an oversized body, and bodies nested 1,000,000 deep: no panic, the server keeps answering, and neither the default log nor trace level repeats any text from the body. I did not run this against the live service, PostgreSQL or Cassandra.

I will approve once the base branch and this branch are updated with main and the checklist matches what was run.

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. At main c057660 (3 December 2026), git merge-tree --write-tree --name-only gives the same three conflicting files for fix(server): parse request bodies nested to the depth the service validates #807 at 71b3e1b and for this PR at 600726b: README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs. fix(server): parse request bodies nested to the depth the service validates #807's branch changes all three. The lib.rs hunk is the one you found. The runtime.rs hunk is the module doc, where fix(server): parse request bodies nested to the depth the service validates #807 names the README section that docs(readme): lead with a first request, move WebAssembly to its own page #1521 moved to docs/webassembly.md. Of the three files, this PR changes only README.md. Its sentence on how the WebAssembly build refuses the PartiQL operations is inside the README hunk. On main that sentence is in docs/webassembly.md, still with the old message. The stack takes main at fix(server): parse request bodies nested to the depth the service validates #807 first. Then each branch merges its parent's new head, so CI runs on the merged trees.

  2. CI's Test workflow passed at 600726b, in run 45570294136 on 25 November 2026. Its run-tests jobs, on stable and on 1.91.1, ran cargo test --locked --workspace --exclude extenddb-backup-store and cargo test --locked -p extenddb-backup-store with no failed test. In each job, the server crate's unit tests gave 530 passed. Testing done now names that run as the workspace run, with its count, in place of the run at e7ef4ad.

@navareamol

Copy link
Copy Markdown
Collaborator

The README item and the stale text. On main the sentence you changed in README.md (the PartiQL refusal that says the build answers a body that does not parse with no message) now lives in docs/webassembly.md, lines 166 to 172, and it still says "Start of structure or map found where not expected". When the stack takes main and the README conflict is resolved, that edit has to go into docs/webassembly.md, or the page will contradict the server again. I checked your description of the three conflicting files against git and it matches what I get at c057660. I think this needs a note in the rebase step. Is the plan to carry the sentence over to docs/webassembly.md?

The description. The Testing done section now names run 45570294136 at 600726b with the workspace command and 530 passed. I read both run-tests jobs (stable and 1.91.1) and they show the same, with no failed test, so the ticked box now has a run behind it.

The conflict list of #530 and #537 in the description: I could confirm #530 changes README.md, but not that #537 does. Can you check that line?

I will approve once the PartiQL sentence is carried into docs/webassembly.md when the stack is rebased onto main, and the #537 line in the description is checked.

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. Yes. This branch takes main through fix(server): parse request bodies nested to the depth the service validates #807, its base. With main at 5826e1b, git merge-tree gives the same three conflicts for fix(server): parse request bodies nested to the depth the service validates #807's head and for this head: README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs. So the stack's merge of main starts at fix(server): parse request bodies nested to the depth the service validates #807. When this branch then merges fix(server): parse request bodies nested to the depth the service validates #807's new head, this PR's change to the PartiQL sentence goes into docs/webassembly.md. Its PartiQL item (lines 166 to 174 on main) still has the old text. The description now says this.

  2. You are right about docs: configuration reference generated from the sample file, pinned to the structs #537. Its own change does not touch README.md. Its head conflicts with this head in README.md only because it sits on docs: architecture dash sweep and one feature status owner #530's branch and contains docs: architecture dash sweep and one feature status owner #530's head 469669e. git merge-tree gives README.md for both heads, and fix(server): parse request bodies nested to the depth the service validates #807's head merges with both with no conflict. The description now names docs: architecture dash sweep and one feature status owner #530 as the PR that conflicts, and says that docs: configuration reference generated from the sample file, pinned to the structs #537's head gets the same conflict through docs: architecture dash sweep and one feature status owner #530.

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

Both points are answered, and I found nothing new at 600726b.

  1. The conflicts. With main at 5826e1b, git merge-tree gives the same three conflicts for this head and for #807's head (71b3e1b): README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs. Of the three, this PR changes only README.md, so the other two come from #807. On main, docs/webassembly.md lines 166 to 174 still say "Start of structure or map found where not expected" for a body that does not parse, so the sentence this PR changes has to go into that item when the stack takes #807's new head. The description now says this, which answers my question.

  2. The #537 line. You are right. #537's own change does not touch README.md. Its head contains #530's head 469669e, and git merge-tree of #537's head and of #530's head each report README.md against this head, while #807's head merges with both with no conflict. #530 changes README.md. The description now names #530 and says #537 gets the conflict through it.

CI at 600726b shows 54 of 54 checks passed and the merge state is CLEAN.

I approve this PR.

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