Repository navigation
fix(streams): answer a ListStreams start ARN that is not a stream ARN with Invalid StreamArn - #1336
LeeroyHannigan wants to merge 3 commits into
Conversation
… 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
left a comment
There was a problem hiding this comment.
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())), |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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.
|
@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 23c9118 merges main at 5826e1b. It also updates those five cases and the two rows of |
What
ListStreamspassed anExclusiveStartStreamArnof 37 characters or more to storage. Thereparse_stream_arnrefused a value that is not a stream ARN withInvalid stream ARN format: <value>. The refusal now carries the sentence DynamoDB gives,Invalid StreamArn. The sentence is a literal inextenddb-storage, which does not depend on the server crate that holds the constant for it.The engine's
Limitand length checks run before the parse, so their order does not change. An emptyStreamArninDescribeStreamandGetShardIteratorreaches the same parser. Those two requests now also getInvalid StreamArn, where main answeredInvalid stream ARN format:. DynamoDB answers both of them withInvalid StreamArn(measured 2026-11-21). A table ARN in those two operations getsInvalid StreamArnfrom 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
GetRecordsiterator that carries one. Five cases incrates/wasm-adapter/parity/corpus.jsonexpected that sentence. They now expectInvalid StreamArn, anddocs/webassembly.mdgives 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
TableNameof the same table.ExclusiveStartStreamArnValidationExceptionInvalid StreamArnInvalid stream ARN format: <value>Invalid StreamArnInvalid stream ARN format: <value>arn:aws:dynamodb:us-east-1:plus 13 charactersInvalid StreamArnInvalid stream ARN format: <value>xyz,x<U+0000>y, 36 characters that are not an ARNexclusiveStartStreamArnlength sentence (37)Limit0limitsentenceThe length check in
handle_list_streams, on main before this change, already answers the issue'sxyzandx<U+0000>yrows.Three rows differ from the service on main and on this branch alike. DynamoDB answers
xyzwithLimit0 with both sentences joined under2 validation errors detected. ExtendDB answers thelimitsentence alone. DynamoDB answers a stream ARN under 37 characters whose table segment fails the pattern with the length sentence. ExtendDB answers it withInvalid StreamArnfrom the server gate. DynamoDB answers a value over 1024 characters with theexclusiveStartStreamArnmaximum length sentence. ExtendDB answers it by shape, and a value over 1024 characters that is not a stream ARN now getsInvalid StreamArnwhere main gave the old sentence. Each has its own issue with the measurement: #1333, #1334, #1335.Testing done
crates/storage/src/util/arn.rspins 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 incrates/server/src/authz_resource.rspins which strings parse as stream ARNs.tests/python/test_list_streams_start_arn.pysends each measured row this change answers as the service does toListStreamsand asserts the status, the error code and the full message. On a build of main, the 11 shape rows fail withInvalid stream ARN formatand 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. Thexyzandx<U+0000>yrows 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.pyandtests/python/test_streams.pypass beside it (102 tests).ListStreamsthrottled 19 of the 24 rows in a run without a retry. The suite's retry after aThrottlingExceptionmoves fromtest_nul_arn_shapes.pytohelpers.py, and both files import it.Invalid StreamArn. With theLimitcheck removed, theLimit0 row getsInvalid 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, andcargo +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).cargo +1.97.0 test --locked -p extenddb-wasm-adapterpasses, the parity test included, and so do the 6util::arntests ofextenddb-storage.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, 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.