Skip to content

fix(server): read a trailing point and a lone minus sign in a request number - #1372

Open
LeeroyHannigan wants to merge 8 commits into
fix/1257-leading-zero-numbersfrom
fix/1343-number-forms
Open

LeeroyHannigan wants to merge 8 commits into
fix/1257-leading-zero-numbersfrom
fix/1343-number-forms

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

What

The server now reads two more number forms in a request body as DynamoDB reads them. It reads a number that ends in a point after its digits, such as 1. or -1., as the digits. It reads a minus sign on its own, -, as 0. Before, a body with either form got a SerializationException with no message, because serde_json refuses both.

The change is in crates/server/src/request_parse.rs. without_leading_zeros from #1344 is now rewrite_numbers, and it adds two rules to the leading zero rule:

  • The pass writes a - that starts a number and has no number byte after it as 0.
  • The pass removes a . after an optional - and digits when no number byte comes after it.

It is still one pass over the body with StringScan, and it does not recurse. The bytes of every string and the nesting do not change. When the pass changes nothing, it returns nothing, and the body is not read again. The two new rules need to know what the number so far holds. One flag cannot carry that, so a four-state Token takes its place. The number bytes come from request_syntax::number_byte, which #1344 at 00ccd3b already calls in place of an inline matches!.

Every other number form stays as sent and gets the refusal it gets now. DynamoDB skips those forms in a member outside its model. In an integer member, it refuses -., 1e, 1.e, 1e5. and 1- with "Message":"Bad number format", and it reads -.5 and 1.e7 as numbers. The step that rewrites the body does not know the member type, so it cannot give both answers. #1343 stays open for those forms.

The security manual's paragraph on the syntax check (docs/manuals/10-security-model.md) now says that the parse after authentication reads 1. as 1 and - as 0.

The WebAssembly build parses a body with serde_json's defaults, so it still refuses both forms (#1471).

The base of this PR is #1344.

Why

These are DynamoDB's answers, measured in us-east-1 on 21 and 22 November 2026 with signed requests. Each request went out twice and got the same answer both times. Every request names a table that does not exist.

  • RNF is ResourceNotFoundException.
  • SE is SerializationException with no message.
  • VE is ValidationException.
Request DynamoDB ExtendDB on #1344 ExtendDB with this PR
DescribeTable with a member x that is not in the model, of value 1. or - RNF SE RNF
Scan, Limit 1. RNF SE RNF
Scan, Limit 0. or - VE, Value '0' at 'limit' SE RNF
Scan, Limit -1. VE, Value '-1' at 'limit' SE RNF
Scan, Segment 0 and TotalSegments 1000001. VE, Value '1000001' at 'totalSegments' SE RNF
Scan, Segment 0 and TotalSegments - VE, Value '0' at 'totalSegments' SE RNF

The rows where DynamoDB answers VE do not match on a missing table. ExtendDB's Scan looks up the table before it checks Limit, Segment and TotalSegments, and DynamoDB checks these ranges first (#850). On a table that exists, each of these Scan rows gets DynamoDB's text. The TotalSegments - row is different: it gets ExtendDB's sentence The parameter TotalSegments should be greater than or equal to 1 (#563).

These answers still differ from DynamoDB, or were not measured:

Refs #1343

Testing done

  • CI's Test workflow passed at 4f689ba (run 45570893865, 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. In each job, the server crate's unit tests gave 530 passed and 0 failed.
  • cargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warnings and cargo +1.97.0 fmt --all -- --check are clean at 90dc032 and at 3f1be69.
  • The rows are in the existing tables, with no new test function. a_body_with_a_syntax_fault_is_refused_with_no_message has rows for the two new forms, a body 1127 levels deep, and the 17 forms that stay refused. At 3f1be69 the 17 run through the parse alone. tests/test_syntax_fault_message.py has 6 new rows.
  • With the production code of request_parse.rs from fix(server): read a number written with leading zeros in a request body #1344 and the tests of this PR, a_body_with_a_syntax_fault_is_refused_with_no_message fails at its first new row.
  • The measured rows went to SQLite servers built from this change and from fix(server): read a number written with leading zeros in a request body #1344's head, each row twice. Each server gave the same answer to both sends, and every form that this PR leaves got the same answer from both servers. tests/test_syntax_fault_message.py passed 33 tests at 90dc032, and 3 of them failed on fix(server): read a number written with leading zeros in a request body #1344's head.
  • On a table with two items, a Scan with Limit 1. returned 1 item. Each other Scan row of the table got the answer that the same body gets with the plain number.
  • 2094 generated bodies went through the parse and the syntax check of both trees. They hold 85 forms of number in lists, objects and nested levels, beside strings with escapes. Each parse got the answer of the body with the plain number, or the refusal. Every body that fix(server): read a number written with leading zeros in a request body #1344 reads got the same value with this PR.
  • The last amend changed only doc comments and the commit message. The test and server runs used the commit before it, and the request_parse tests ran on the last commit.

Line counts of this PR's own change at 4f689ba: production +63 -25, of which +33 -8 is code and the rest is comments. The tests are +60 -18. One line of the security manual changes.

git merge-tree of 4f689ba shows no conflict with #1265 at 53d0c75. The branch contains #1344 at 693b815, #1261 at 600726b, #807 at 71b3e1b and main at b0d1c64. 28 open PRs outside #807, #1261, #1265, #1344 and #1372 change docs/manuals/10-security-model.md. Of these, only #140 conflicts with this branch in that file, and it has the same four conflict hunks with main.

With main at c057660 (3 December 2026), git merge-tree of 4f689ba reports conflicts in README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs. #1344 at 693b815, #1261 at 600726b and #807 at 71b3e1b have the same three conflicts. This PR changes none of the three files.

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 server now reads a number that ends in a point after its digits, such as 1. or -1., as the digits. It reads a minus sign alone, -, as 0. A request with either form now gets the answer of the same request with the plain number. Before this change, it got a SerializationException with no message. For example, on a table with two items, a Scan with Limit 1. now returns 1 item. In a string, boolean or map member, the two forms now get the SerializationException text that a plain number gets in that member. A body that is only - or 1. now reaches authentication, and signed it gets the text that a body of 5 gets (#1012).


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.

… number

ExtendDB refused a request body with a number that ends in a point, such
as 1., with a SerializationException. It refused a minus sign on its own
the same way, because serde_json refuses both forms. DynamoDB reads
both. Outside its model it skips a number of either form unread. In an
integer member it reads 1., 0., -1. and 1000001. as 1, 0, -1 and
1000001, and a minus sign on its own as 0. Measured in us-east-1 on 21
Nov 2026, with Scan Limit and TotalSegments on a table that does not
exist.

The pass that removes the leading zeros of a refused body now also
removes a point that ends a number after its digits. It writes 0 for a
minus sign that is a whole number. It is still one pass over the body,
and it does not recurse. The bytes of strings and the nesting do not
change. Every other number stays as sent, so ExtendDB refuses -., 1e,
1.e, 1e5., 1- and -.5 as before. DynamoDB refuses the first five in an
integer member with "Bad number format", and it reads -.5 as a
fraction. ExtendDB reads a body that serde_json accepts in one pass, as
before.

Refs #1343.
Merges 00ccd3b of fix/1257-leading-zero-numbers. That brings in
fix/1195-syntax-fault-message at 748d21e and fix/request-nesting-depth
at 4c2995c, with the merge commits of both branches. The 4c2995c
head holds the syntax scan with the service's grammar in
request_syntax.rs and the merges of main at 44cd436 and 6aef346.

Conflicts and their resolution, all in crates/server/src/request_parse.rs:

- check_request_syntax: this branch's doc comment said a number that
  rewrite_numbers rewrites passes the check. The check is now
  request_syntax::skip_value, which passes `01`, `1.`, `1e` and `-` as
  sent. Kept: the other branch's doc comment. The read_json wrap went
  in the other branch's merge, so none is here.
- rewrite_numbers, the token state: this branch's Token match stays. The
  other branch's at_start line belonged to without_leading_zeros, which
  this branch replaced.
- a_body_with_a_syntax_fault_is_refused_with_no_message: both branches
  added rows. Kept: this branch's trailing point and lone minus rows and
  the other branch's seven leaf faults, with one comment.

The second number_byte goes: rewrite_numbers calls
request_syntax::number_byte, which has the same body and doc sentence.

The refused numbers of the test now run through the parse alone. Before
authentication skip_value reads a number as `-` or a digit and then any
run of number bytes. So it passes `1e`, `--1` and the other rows that
start that way, where serde_json's skip refused them. The parse still
refuses each of the seventeen with no message.
Merges 68f0379, the one commit of fix/1257-leading-zero-numbers since
00ccd3b. It changes one sentence of the security manual. No conflict.
The security manual's paragraph on the syntax check names the forms the
check passes to authentication. On this branch the parse after
authentication reads `1.` as 1 and `-` as 0, beside a number written
with leading zeros, and refuses the other forms. The paragraph now says
so.
Merges 54ed1f2 of fix/1257-leading-zero-numbers, its merge of
fix/1195-syntax-fault-message at 0986467. That brings in
fix/request-nesting-depth at b9baaf5, which merges main at 018715e,
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 61eee55 of fix/1257-leading-zero-numbers, its merge of
fix/1195-syntax-fault-message at 654fef3. That brings main at
b0d1c64 (#1280, #1009 and #596). It also brings the commit that makes
the handler call extenddb_engine::check_operation and
with_body(input).admit() around the server's parse. The README item on
the PartiQL operations now says that a server answers a body that does
not parse with no message.

No conflicts. None of these commits changes a file of this branch.
Merges 7ad2a44 of fix/1257-leading-zero-numbers, its merge of
fix/1195-syntax-fault-message at 7d7a089. That brings three commits:

- the merge of fix/request-nesting-depth at 027483d, which changes one
  sentence of the WebAssembly adapter's module doc
- 3f5ccff, after which the helper _is_messageless_serialization_error
  of tests/test_request_nesting_depth.py compares the whole error
  document
- 7d7a089, after which REQ-ERR-002 in docs/design/01-requirements.md
  says that a SerializationException for a body that does not parse has
  no message field

No conflicts. None of these commits changes a file of this branch.
Merges 693b815 of fix/1257-leading-zero-numbers, its merge of
fix/1195-syntax-fault-message at 600726b. That brings 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.

One conflict, in the comment of
a_body_with_a_syntax_fault_is_refused_with_no_message in
crates/server/src/request_parse.rs. The resolution keeps this branch's
text on the rows with a trailing point or a minus sign on its own. It
also names the eight new rows with their measurement. The eight rows
auto-merged into the table with None. rewrite_numbers rewrites no number
in them, so the parse refuses each with no message.

tests/test_request_nesting_depth.py auto-merged with the other branch's
rows.

@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. The head does not merge cleanly with current main. A trial merge of 4f689ba with main at 92155f3 conflicts in README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs. This PR changes none of them, and #1344 at 693b815 has the same three conflicts with main, so they come from main moving under the stack. I kept both lines in lib.rs (main's test_context module and the branch's wider pub use) and the branch side of the two doc comments. That tree builds, test_syntax_fault_message.py and test_request_nesting_depth.py pass 138 of 138 on SQLite, and my probes of the new forms answer as on the head. CI ran on the branch, not on a tree with main in it. Could the stack be brought up to date with main when #807, #1261 and #1344 move, so CI runs on the merged code?

  2. One number in Testing done comes from an older revision. It gives 506 passed for the server crate tests at 90dc032. At the head, the server crate's unit tests give 530 passed and 0 failed here. The checklist ticks cargo test --workspace, and I could not find a workspace run described for any revision. I think the count should be updated to the head, or the box unticked.

I will approve once the Testing done count matches the head.

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. At main c057660 (3 December 2026), git merge-tree gives the same three conflicting files for this head 4f689ba and for the three heads below it. Those heads are fix(server): read a number written with leading zeros in a request body #1344 at 693b815, fix(server): send no message for a body with a JSON syntax fault #1261 at 600726b and fix(server): parse request bodies nested to the depth the service validates #807 at 71b3e1b. The files are README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs. This PR changes none of them. 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 4f689ba, in run 45570893865 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, the count you got. Testing done now names that run as the workspace run, in place of the 506 at 90dc032.

@navareamol

Copy link
Copy Markdown
Collaborator

The description now matches the head. It names run 45570893865 at 4f689ba with the two workspace cargo commands, and I read 530 passed and no failed test in both run-tests jobs, stable and 1.91.1. The old 506 count is gone, so the ticked workspace box has a run behind it.

The three conflicting files at main c057660 are README.md, crates/engine/src/lib.rs and crates/wasm-adapter/src/runtime.rs, the same ones I get for this head and for the three heads below it, and this PR changes none of them. The stack order you describe is what I would expect.

I have no further findings on the code. My earlier checks of the head still hold, since it did not move.

I will approve once the stack is rebased onto main and CI has run on the merged tree.

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