Skip to content

fix(server): answer by media type, method and path as DynamoDB does - #1079

Open
LeeroyHannigan wants to merge 6 commits into
mainfrom
fix/1020-http-routes
Open

LeeroyHannigan wants to merge 6 commits into
mainfrom
fix/1020-http-routes

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

What

This PR has two commits. The first is the fix below. The second updates one Rust integration test, which expected ExtendDB to answer GET / with 405. With the fix, GET / gets the health text, as on DynamoDB.

ExtendDB now answers a request by its media type, its method and its path, as DynamoDB does.

  • A POST at any path reaches the API. ExtendDB serves it when the Content-Type is application/x-amz-json-1.0 or application/json, in any letter case and with or without parameters. The answer comes back in the media type of the request.
  • A POST whose body is over 16 MiB gets 413 in every media type, as on DynamoDB. This holds for a body sent with a Content-Length and for a chunked body.
  • A smaller POST in another media type, or with no Content-Type, gets the DynamoDB 404 page. ExtendDB reads the body through the limit first. Then it sends the page, before it reads the signature, the X-Amz-Target and the JSON, as DynamoDB does.
  • GET / with no query string and GET /ping get the text healthy: dynamodb.<region>.amazonaws.com in text/plain, with no authentication. The text holds only the configured region.
  • Any other request gets the 404 page. HEAD gets the 404 with no body. Each of these answers carries an x-amzn-RequestId and the X-Amz-Crc32 of its body.
  • The signature covers the path and the query string of the request. Before this change, ExtendDB assumed POST / with no query string. A request signed for one path now fails at another, as on DynamoDB.

ExtendDB's own routes keep their answers: /health keeps its JSON, /metrics keeps its admin authentication, and the routes under /management and /console keep their own authentication. A path under /management or /console with no route keeps its empty 404, and a POST to /health or /metrics keeps its 405. DynamoDB serves the API at those paths, and docs/differences-from-dynamodb.md now has a row for this difference.

How the code does it:

  • The router's fallback, in the new crates/server/src/wire_routes.rs, answers each request that no ExtendDB route takes. It sits behind the same layers as the old POST / route, with the 16 MiB body limit.
  • The fallback tests the /management and /console prefixes itself. A server without a catalog store mounts neither router, and the prefix test keeps the empty 404 there too.
  • AuthProvider::authenticate takes the path and the query string. canonical_request builds the SigV4 canonical URI and canonical query string from them.
  • One function in response.rs adds the request id and CRC32 headers for success_response, error_response, the page and the health text.

No measurement settles one rule of the canonical URI. For a path that ends in /. or /.., ExtendDB keeps the final slash, as the AWS SDK for Rust signer does. botocore drops it, so ExtendDB refuses a botocore request signed for such a path with InvalidSignatureException.

Other open PRs that this change meets:

Why

The answers are DynamoDB's, measured in us-east-1. I measured the issue's rows on 14 November 2026. On 17 November 2026, requests showed the order of the rules, the signature, GET /ping with a query string and the 413 over 16 MiB. Each request went out twice and got the same answer both times. This PR leaves the empty body of DynamoDB's 413 to #1076, and the error type of a request with no Authorization header to #1075.

Closes #1020

Merge of #1003

84a75b3d9 merges main at a60c2b9f3 (#1003). In crates/auth/src/lib.rs, verify_signature takes main's cached signing key and this branch's path and query string. The sigv4_differential harness builds main's provider over a pass-through credential cache. The follow-up b4967521f gives the two-argument authenticate shim of tests.rs the type BuiltinAuthProvider, which #1003 made non-generic.

At b4967521f, cargo +1.97.0 test --locked -p extenddb-auth --lib gives 533 passed, and the sigv4_differential suite 15 passed. cargo +1.97.0 test --locked -p extenddb-server --lib gives 515 passed, and 5 backup_store tests fail because of the test host's sandbox user.

Merges of 24 November

f2d4555f6 merges main at 018715e0d (#774). In crates/server/src/response.rs both sides add a block after the imports, and the merge keeps both.

e47661ff7 merges main at 3534c9e4d (#1009), which moved the error body to extenddb_core::error::error_document. In crates/server/src/response.rs the merge keeps this branch's wire_response and drops the local copy of SERIALIZATION_FAILURE_BODY, which main now imports from crates/core/src/error/mod.rs. Cargo.lock is main's, with this branch's urlencoding dependency of extenddb-auth added back. #1009 replaced the axum dependency of extenddb-auth with http, so tests/sigv4_differential/paths.rs reads Uri from http.

At e47661ff7, with --locked:

  • cargo +1.97.0 check --workspace --all-targets is clean.
  • cargo +1.97.0 test -p extenddb-auth --lib gives 533 passed, and the sigv4_differential suite 15 passed.
  • cargo +1.97.0 test -p extenddb-server --lib gives 516 passed, and the 5 backup_store tests fail because of the test host's sandbox user.
  • cargo test -p extenddb-wasm-adapter passes its 3 tests and the parity corpus.
  • Clippy with -D warnings on the auth and server crates, and cargo fmt --check, are clean.

Testing done

On the fix commit:

  • cargo test -p extenddb-auth: 533 passed. The signer comparison tests sign requests for 9 paths and query strings with the AWS SDK for Rust signer. Each request passes at its own target and fails at another.
  • cargo test -p extenddb-server --lib: 503 passed. 5 backup_store tests fail on the test host on main too, because of its sandbox user.
  • tests/test_http_routes.py: 54 passed on the SQLite backend over TLS. In dev mode over plain HTTP, 54 passed on the previous version of the commit, before the last change to the size rule. tests/test_auth_error_fidelity.py: 27 passed on the SQLite backend.
  • cargo +1.97.0 clippy -p extenddb-auth -p extenddb-server --all-targets -- -D warnings and cargo fmt --check are clean.

Line counts: production +252 -56, tests +548 -54, docs +15 -10.

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: none. The change brings the wire answers to DynamoDB's measured ones, and it changes the AuthProvider trait (see Breaking changes).

Breaking changes

  • A POST to / in a media type other than application/x-amz-json-1.0 or application/json, or with no Content-Type, now gets a 404. Before, ExtendDB served it.
  • AuthProvider::authenticate takes two more arguments, the path and the query string.

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.

Amazon DynamoDB serves its API for a POST at any path when the
Content-Type is application/x-amz-json-1.0 or application/json. It
compares the media type without its parameters and in any letter case,
and it answers in that media type. A POST whose body is over the 16 MiB
limit gets 413 in every media type. Under the limit, a POST in any other
media type, or with none, gets a 404 with an HTML page and no
Content-Type. This 404 comes ahead of authentication and of the
X-Amz-Target, operation and JSON checks. A GET of / with no query
string, or of /ping with or without one, gets the text
"healthy: dynamodb.<region>.amazonaws.com " in text/plain. Every other
request gets the 404 page, and HEAD gets it without the body. Each
answer but the 413 carries an x-amzn-RequestId and the X-Amz-Crc32 of
its body. The signature covers the request's path and query string.

ExtendDB served the API for POST / only, in any media type, and answered
in application/x-amz-json-1.0 only. Other methods and paths got a 405 or
a 404 with no body and no X-Amz-Crc32. The signature check used / with
no query string, whatever the request's target.

The router now has a fallback in place of the POST / route. The fallback
serves the API for a POST at any path, under the 16 MiB body limit and
behind the same layers as before. It also gives the health text and the
404 page. In another media type, it reads the body through the limit
first, so a body over it gets the handler's 413 however it is framed.
A path under /management or /console that their routers do not take
keeps its empty 404. The signature check builds the canonical URI and
query string from the request's own path and query string.

The issue's rows were measured in us-east-1 on 2026-11-14. Requests to
us-east-1 on 2026-11-17 showed where the size check and the media type
check come among the other checks. They also showed that the signature
covers the path and query string.

Fixes #1020.
Amazon DynamoDB answers GET / with 200 and a text/plain health line
(measured in us-east-1 on 2026-11-14 for #1020). With the change for
#1020, ExtendDB gives the same answer. The raw HTTP test that expected
405 from ExtendDB now expects the health text from both targets.
crates/auth/src/lib.rs keeps the cached signing key of main (#1003) and the request's path and query string of this branch in the call to verify_signature.

crates/auth/tests/sigv4_differential/harness.rs keeps the provider over a pass-through credential cache from main and the path and query string arguments of authenticate_at from this branch.
… of main

Main (#1003) removed the store type parameter of BuiltinAuthProvider, so BuiltinAuthProvider<MockCredentialStore> no longer names a type. The unit tests in tests.rs build each provider through provider_over, over a pass-through CachedCredentialStore.

The shim that sends the unit tests' requests to authenticate with the path / and no query string is now an impl block on BuiltinAuthProvider. Its body does not change.
Main's #1009 moved the error body to `extenddb_core::error::error_document`
and `SERIALIZATION_FAILURE_BODY` to `crates/core/src/error/mod.rs`. In
`crates/server/src/response.rs` the merge keeps this branch's
`wire_response` and drops the local copy of the fallback body, which main
now imports from core.

#1009 also replaced the `axum` dependency of `extenddb-auth` with `http`,
so the new `tests/sigv4_differential/paths.rs` of this branch reads `Uri`
from `http`. `Cargo.lock` is main's, with this branch's `urlencoding`
dependency of `extenddb-auth` added back.

@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 e47661f. The auth and server crate tests, the sigv4_differential suite, and test_http_routes.py with test_auth_error_fidelity.py on PostgreSQL (81 passed) ran at this head, plus a probe run against main. The review covers how the wire-answer changes are documented for upgrades.

Docs — outside the diff

  1. docs/manuals/07-upgrade-manual.md:385 — Please add an entry under Behavior Changes by Release for the clients this change stops serving. A signed ListTables POST / from a scratch probe got 200 on main with no Content-Type, with text/plain and with application/x-amz-json-1.1. At this head all three get the 404 page, and GET / changes from 405 to 200 healthy: dynamodb.us-east-1.amazonaws.com . An entry that names the two served media types, the GET / and /ping answers, and the new AuthProvider::authenticate arguments would close this.

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

The branch no longer builds its auth tests against current main. #949 is on main now (5252eda) and added crates/auth/src/scope_tests.rs, which calls provider(false).authenticate(&headers, b"{}") with two arguments. The two-argument shim this PR adds at crates/auth/src/tests.rs line 178 is private to mod tests, and scope_tests is a sibling module, so those calls go to the four-argument trait method. I merged origin/main into e47661f locally (no text conflict) and cargo test -p extenddb-auth stops with 12 E0061 errors, "this method takes 4 arguments but 2 arguments were supplied", at scope_tests.rs lines 32, 80, 100, 117, 204, 260, 263, 300, 314, 342, 396 and 417. The green checks on this head ran on a merge of 3534c9e, before #949. Changing the shim to pub(crate) async fn authenticate fixed it here: 534 lib tests and 15 sigv4_differential tests pass on the merged tree. Could you merge main and push that change, or pass "/" and "" in scope_tests.rs?

botocore signs some query strings in a form the new canonical_query_string refuses. I signed a ListTables with botocore 1.43.127 for each target below and sent it to that same target on a SQLite server built from this head. /?s=a+b, /?t=%7E and /?a=1&&b=2 got InvalidSignatureException. /?t=~, /?b=2&a=1, /?c, /?k=v%2Fw and /?A=1&a=1 were served. botocore's _canonical_query_string_url keeps each pair as sent and sorts them, so it signs s=a+b, t=%7E and an empty pair as =. This PR reads + as a space, decodes %7E to ~ and drops empty pairs, which is what the Rust SDK signer does in paths.rs. Main refuses all of these too, so this is not a regression, but the description names only the /. and /.. path case as a gap with botocore. Has anyone sent these three botocore requests to DynamoDB? If DynamoDB serves them, I think the query rule needs to accept what both signers send. If it refuses them, could you add the three rows to TARGETS in tests/test_http_routes.py so the live run pins the answer, and name these query forms next to the /. note in the description?

I will approve once the branch builds its auth tests on current main and the botocore query rows have a measured answer in the tests or a note in the description.

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

3 participants