Skip to content

fix(streams): answer a ListStreams start ARN that is not a stream ARN with Invalid StreamArn - #1336

Open
LeeroyHannigan wants to merge 3 commits into
mainfrom
fix/906-liststreams-start-arn
Open

LeeroyHannigan wants to merge 3 commits into
mainfrom
fix/906-liststreams-start-arn

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

What

ListStreams passed an ExclusiveStartStreamArn of 37 characters or more to storage. There parse_stream_arn refused a value that is not a stream ARN with Invalid stream ARN format: <value>. The refusal now carries the sentence DynamoDB gives, Invalid StreamArn. The sentence is a literal in extenddb-storage, which does not depend on the server crate that holds the constant for it.

The engine's Limit and length checks run before the parse, so their order does not change. An empty StreamArn in DescribeStream and GetShardIterator reaches the same parser. Those two requests now also get Invalid StreamArn, where main answered Invalid stream ARN format: . DynamoDB answers both of them with Invalid StreamArn (measured 2026-11-21). A table ARN in those two operations gets Invalid StreamArn from the server gate, on main and on this branch.

The WebAssembly build has no server gate. So its handler gave the old sentence for a table or backup ARN in those two operations, and for a GetRecords iterator that carries one. Five cases in crates/wasm-adapter/parity/corpus.json expected that sentence. They now expect Invalid StreamArn, and docs/webassembly.md gives the new answer in its StreamArn kind and GetRecords iterator scope rows.

Why

Fixes #906

Measured in us-east-1 on 2026-11-21 with SDK parameter validation off, each row twice. A table ARN was also sent with the TableName of the same table.

ExclusiveStartStreamArn DynamoDB ExtendDB at 8c64333
a table ARN of the caller's account, existing or not, with or without U+0000 in the table segment ValidationException Invalid StreamArn Invalid stream ARN format: <value>
an index ARN, a backup ARN, a stream ARN with a trailing slash Invalid StreamArn Invalid stream ARN format: <value>
37 or 40 characters that are not an ARN, or arn:aws:dynamodb:us-east-1: plus 13 characters Invalid StreamArn Invalid stream ARN format: <value>
xyz, x<U+0000>y, 36 characters that are not an ARN the exclusiveStartStreamArn length sentence (37) the same
a table ARN with Limit 0 the limit sentence the same
a stream ARN of another region, account, partition or service, with an empty region or account, or of a table or label the account never had 200 200

The length check in handle_list_streams, on main before this change, already answers the issue's xyz and x<U+0000>y rows.

Three rows differ from the service on main and on this branch alike. DynamoDB answers xyz with Limit 0 with both sentences joined under 2 validation errors detected. ExtendDB answers the limit sentence alone. DynamoDB answers a stream ARN under 37 characters whose table segment fails the pattern with the length sentence. ExtendDB answers it with Invalid StreamArn from the server gate. DynamoDB answers a value over 1024 characters with the exclusiveStartStreamArn maximum length sentence. ExtendDB answers it by shape, and a value over 1024 characters that is not a stream ARN now gets Invalid StreamArn where main gave the old sentence. Each has its own issue with the measurement: #1333, #1334, #1335.

Testing done

  • A unit test in crates/storage/src/util/arn.rs pins the refusal for a table ARN and for a value that is not an ARN. Each row is one path into the refusing arm. The shared parser's test in crates/server/src/authz_resource.rs pins which strings parse as stream ARNs.
  • tests/python/test_list_streams_start_arn.py sends each measured row this change answers as the service does to ListStreams and asserts the status, the error code and the full message. On a build of main, the 11 shape rows fail with Invalid stream ARN format and the 13 other rows pass. On this branch all 24 pass against a dev-mode SQLite server, and all 24 pass against DynamoDB in us-east-1, in two runs. The xyz and x<U+0000>y rows stay although main already answers them as the service does, because ListStreams: an ExclusiveStartStreamArn that is not a stream ARN answers "Invalid stream ARN format", where DynamoDB answers Invalid StreamArn or a length fault #906 lists them. test_nul_arn_shapes.py, test_stream_disable_validation.py and tests/python/test_streams.py pass beside it (102 tests).
  • Against the service, ListStreams throttled 19 of the 24 rows in a run without a retry. The suite's retry after a ThrottlingException moves from test_nul_arn_shapes.py to helpers.py, and both files import it.
  • Four mutants, each caught. With the old sentence restored, the unit test and 11 wire rows fail. With a table ARN read as a stream with an empty label, the unit test and 5 wire rows get 200. With the length check removed, 3 wire rows get Invalid StreamArn. With the Limit check removed, the Limit 0 row gets Invalid StreamArn.
  • cargo +1.97.0 fmt --all -- --check, cargo +1.97.0 clippy -p extenddb-storage --all-targets -- -D warnings, the same with -p extenddb-engine --features extenddb-engine/backup-test-hooks, and cargo +1.91.1 check -p extenddb-storage --all-targets.
  • cargo +1.97.0 test -p extenddb-storage (285 passed) and -p extenddb-engine (871 passed).
  • After the merge of main at 5826e1b: cargo +1.97.0 test --locked -p extenddb-wasm-adapter passes, the parity test included, and so do the 6 util::arn tests of extenddb-storage.

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


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.

… with Invalid StreamArn

ListStreams passed an ExclusiveStartStreamArn of 37 characters or more
to storage. There parse_stream_arn refused a value that is not a stream
ARN with "Invalid stream ARN format: <value>". A table ARN, an index ARN,
a backup ARN and a stream ARN with a trailing slash all got that
sentence. So did 40 characters that are not an ARN and an arn: value of
four fields.

DynamoDB answers each of them with ValidationException "Invalid
StreamArn" (measured in us-east-1 on 2026-11-21, twice per shape). A
table ARN was also sent with the TableName of the same table. DynamoDB
gives the same sentence for a table ARN in DescribeStream and
GetShardIterator, which the server gate already answers. The partition,
service, region and account of a stream ARN are not checked. Another
region, account, partition or service, an empty region or account, and a
table or label the account never had all get a 200 page. The length
sentence comes first for a value under 37 characters, and the Limit
sentence first for Limit 0 beside a table ARN.

parse_stream_arn now refuses with "Invalid StreamArn". The engine's Limit
and length checks run before it, so their order stays as measured. An
empty StreamArn in DescribeStream and GetShardIterator reaches the same
parser. Those two requests now also get "Invalid StreamArn", where main
answered "Invalid stream ARN format: ". DynamoDB answers both of them
with "Invalid StreamArn" (measured 2026-11-21).

A storage unit test pins the refusal for a table ARN and for a value
that is not an ARN. A wire test in the tests/python suite sends each
measured row this change answers as the service does to ListStreams. It
asserts the status, the error code and the full message. The suite's
ListStreams retry after a ThrottlingException moves from
test_nul_arn_shapes.py to helpers.py, and both files import it.

Fixes #906
demohan
demohan previously approved these changes Nov 30, 2026

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

ListStreams answers a start value that is not a stream ARN as the service does at 077e2e2. Of 98 shapes sent twice to the us-east-1 streams endpoint and to this head and main on SQLite and PostgreSQL (table and index ARNs, another account's or region's stream and table ARN, malformed values, an empty string, 36, 1024, 1025 and 5000 characters, a deleted table's stream ARN, each alone, with TableName and with Limit), this head fixes 49 and regresses none, the two backends agree, and a Limit 1 walk from a valid start ARN pages as before. The new test file passes 24 of 24 here on both backends and live and fails the same 11 rows on main, the stream suites pass 102 of 102, the controls fail as they should, fmt, both clippy jobs and the 1.91.1 check are clean, and it merges onto main at 222d80a without conflict and builds and passes the 1.94.0 check there. No merged PR fixes #906.

_ => Err(StorageError::Validation(format!(
"Invalid stream ARN format: {arn}"
))),
_ => Err(StorageError::Validation("Invalid StreamArn".to_owned())),

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.

Optional. Main now has extenddb_core::error::INVALID_STREAM_ARN (core/src/error/messages.rs:44), and storage already depends on core, so the reason in the body for the literal no longer holds. The doc comment above and the body say an empty StreamArn in GetShardIterator changes too, but main answers Invalid StreamArn there since #468; only the DescribeStream half changes.

raw_client.delete_table(TableName=name)
wait_for_deleted(raw_client, name)
except Exception:
pass

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.

Optional. This discards any error from deleting the table, so a run against the service could leave one behind unseen. The file also has no row for an empty string (the service gives the length-37 sentence) or exactly 1024 characters (Invalid StreamArn), both of which this head answers as the service does.

@LeeroyHannigan
LeeroyHannigan added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 2, 2026
@LeeroyHannigan
LeeroyHannigan added this pull request to the merge queue Dec 3, 2026
This branch makes parse_stream_arn answer Invalid StreamArn. Since #1009,
five cases of the WebAssembly parity corpus send a value that is not a
stream ARN to that parser. Three send a table or backup ARN as the
StreamArn of DescribeStream or GetShardIterator. Two send a GetRecords
iterator that carries a table ARN or a value that is not an ARN. They
expected the old sentence, so the parity test failed in the merge queue
on main at 5826e1b.

The five cases now expect Invalid StreamArn. In docs/webassembly.md, the
StreamArn kind and GetRecords iterator scope rows give this build's new
answer.
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 4, 2026
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@demohan the merge queue removed this PR twice for the WebAssembly parity test, on 2 Dec and today. #1009 added five parity cases that expect the old sentence for a value that is not a stream ARN. This PR now gives Invalid StreamArn there, the answer the server gate already gives.

23c9118 merges main at 5826e1b. It also updates those five cases and the two rows of docs/webassembly.md that name the sentence. The parity test and the util::arn tests pass. Could you approve again?

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

2 participants