Skip to content

fix(engine): answer a missing or malformed BackupArn as DynamoDB does - #1327

Open
LeeroyHannigan wants to merge 7 commits into
fix/1263-backup-arn-typefrom
fix/1272-invalid-backup-arn
Open

LeeroyHannigan wants to merge 7 commits into
fix/1263-backup-arn-typefrom
fix/1272-invalid-backup-arn

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

  • 0ee652026f merges fix(server): refuse a BackupArn or TableName of another JSON type first #1291's new head 06402b5de0, which contains main at b3510a93ee. It has one conflict, in README.md: docs(readme): lead with a first request, move WebAssembly to its own page #1521 moved the WebAssembly section of the README to docs/webassembly.md. The merge keeps the README of main and makes the three README edits of this PR in docs/webassembly.md. These are the DescribeBackup text Invalid Backup ARN, the RestoreTableFromBackup row of table names and the BackupArn kind row. The other lines this PR changes stay the same.
  • e3672395cb: the wire table of test_backup_and_table_names_are_validated sends the headline rows of the table below. They are an absent and a null BackupArn on the three operations, an upper-case backup id, an S3 ARN, and the BackupArn values x and bad with the target ab. The engine table of malformed ARNs gets the ids éé, € and ééé, which show that the short id rule counts characters. It also gets an id in mixed case. DynamoDB gave each of these answers on 3 December 2026.
  • The description gives those measurements, the conflicts and the test runs at the new head.

What

RestoreTableFromBackup, DescribeBackup and DeleteBackup now answer an absent or malformed BackupArn with DynamoDB's texts, in DynamoDB's order.

  • Invalid Backup ARN is the answer to an absent, null or empty BackupArn, and to a string that is not a backup ARN of the right shape. It is also the answer to a table segment outside the name pattern and to an ARN over 1024 characters. A backup id of fewer than 3 characters gets it too. The rule counts characters, so éé (4 bytes) gets it.
  • Invalid Request: BackupArn is not valid is the answer to a backup id of 3 characters or more that is not a backup id, a control character in it included. It is also the answer to an ARN of the caller's account in another partition. DescribeBackup and DeleteBackup also give it to a region outside [a-z0-9-].
  • On a restore, an ARN whose account field is not the caller's gets AccessDeniedException and Access is denied before both texts, an S3 ARN included. The rule does not cover a backup ARN whose table segment is outside the pattern, or an ARN with an empty resource (DescribeBackup and DeleteBackup answer Invalid Backup ARN to an ARN of another account that is not a backup ARN, where DynamoDB answers AccessDeniedException #1354).
  • A backup id of the right shape with hex digits in upper case, all or some of them, gets BackupNotFoundException in the aws partition. In another partition it gets Invalid Request: BackupArn is not valid.

A restore answers the account and the Invalid Backup ARN shapes before its TargetTableName. It answers the backup id, the region and the partition after the name.

The changes:

  • check_backup_arn in crates/core/src/backup_format/layout.rs sorts its refusals into these classes. The new class BackupArnError::Region holds a region outside [a-z0-9-]. The set of ARNs that the parser accepts does not change.
  • In crates/engine/src/backup.rs, backup_arn_member reads an absent BackupArn as an empty one and compares the account field first. backup_arn_refusal in crates/engine/src/backup_requests.rs maps each class to its text, for the BackupArn and for the ListBackups cursor.
  • The new check_restore_backup_arn gives the checks that a restore makes before its name. When crates/server/src/table_name_gate.rs refuses a restore's TargetTableName, it calls this function first.
  • No build makes a backup id in upper case, so in the aws partition the engine answers one as not found without a lookup.
  • docs/differences-from-dynamodb.md, docs/dynamodb-limits.md and docs/webassembly.md, the page of the WebAssembly build, describe these texts and this order. The parity corpus of the WebAssembly build records the new texts.

The ListBackups ExclusiveStartBackupArn gets the new class texts. Its account is still compared after its shape.

The base of this PR is #1291.

Why

These are DynamoDB's answers, measured in us-east-1 on 21 November 2026, and on 25 November 2026 for the aws-cn row with the upper-case backup id. Each request went out twice and got the same answer both times. No request names a backup that exists. A restore has a valid target name unless the row gives another one.

  • IBA is Invalid Backup ARN.
  • NV is Invalid Request: BackupArn is not valid.
  • NULL is 1 validation error detected: Value null at 'backupArn' failed to satisfy constraint: Member must not be null.
  • LENGTH is TableName must be at least 3 characters long and at most 255 characters long.
  • AD is AccessDeniedException with Access is denied.
  • BNF is BackupNotFoundException.
Request DynamoDB ExtendDB on #1291 ExtendDB with this PR
The three operations, no BackupArn or a null one IBA NULL IBA
The three operations, BackupArn "" or a table segment of 1000 characters IBA NV IBA
RestoreTableFromBackup, BackupArn x, arn:, not-an-arn, arn:aws:dynamodb or an ARN with a field missing IBA NV IBA
RestoreTableFromBackup, a table ARN, a stream ARN, an index ARN or an empty backup id IBA NV IBA
RestoreTableFromBackup, a string of 1025 x characters IBA NV IBA
RestoreTableFromBackup, the backup id bad NV IBA NV
The three operations, a backup id 01791976431438-*, or one with 7 or 9 hex digits, a g or an x in the digits NV IBA NV
The three operations, a backup id of 14 digits and 8 hex digits in upper case BNF IBA BNF
RestoreTableFromBackup and DescribeBackup, the same id in upper case with the caller's account in the aws-cn partition (25 November 2026) NV IBA NV
RestoreTableFromBackup, an S3 ARN AD NV AD
RestoreTableFromBackup, an S3 ARN, target name a* AD LENGTH AD
RestoreTableFromBackup, a table ARN, target name a* IBA LENGTH IBA
RestoreTableFromBackup, no BackupArn, target name a* IBA LENGTH IBA
RestoreTableFromBackup, BackupArn x, target name ab IBA NV IBA
RestoreTableFromBackup, the backup id bad, target name ab LENGTH IBA LENGTH
RestoreTableFromBackup, the caller's account in the aws-cn partition, target name ab LENGTH NV LENGTH
RestoreTableFromBackup, an upper-case region, U+0000 in the backup id or an upper-case backup id, target name ab LENGTH NV or IBA LENGTH

On 3 December 2026 DynamoDB answered DescribeBackup with the backup ids é (2 bytes), éé (4 bytes) and € (3 bytes) with IBA, and ééé with NV. It answered the id 01791976431438-73D8d5bc in mixed case with BNF and the ARN as sent, on DescribeBackup and on a restore. The same day it gave the headline rows of the table the answers shown. These rows are no BackupArn or a null one on the three operations, the upper-case id, the S3 ARN, and x and bad with ab. This head gives the same answers.

Both trees already answer AD for another account and for an empty account field. For the aws-cn row with the upper-case id, the #1291 column comes from its code: #1291 answers that class of id with IBA.

The rows went to a SQLite server built from this head on 25 November 2026. On 21 November they went to one built from 5aa21734b, the first commit of #1291. Of 124 measured requests to the three operations, this head gives DynamoDB's answer to 117 and 5aa21734b gives it to 66. No request that 5aa21734b answers as DynamoDB does gets another answer here. Four of the other 7 are a backup of another region and three region fields on a restore (#1326). The last three are an ARN with a trailing \n, one on each operation (#617). Of 30 ListBackups cursor rows, this head gives DynamoDB's answer to 13 and 5aa21734b to 7. #907 tracks the others.

39 more requests cover inputs that no row above covers. They have null members, other partitions, upper-case region fields and backup ids, or ARNs of another account that are not backup ARNs. They went to DynamoDB on 21 November 2026, and to this head on 25 November. This head gives DynamoDB's answer to 29 of them. 30 of them also went to 5aa21734b, which gives DynamoDB's answer to 8 of those. Of the other 10, three are cursor rows (#907), and one is an upper-case region field on a restore (#1326). Two have an empty region field, and the IAM policy of the measuring credentials refused them, so their answer is not measured. The last four are a DescribeBackup or a DeleteBackup of an ARN of another account that is not a backup ARN, an S3 ARN included. DynamoDB answers AD to them, and this head answers IBA (#1354).

Fixes #1272

Testing done

At e3672395cb, each cargo command with --locked:

  • cargo +1.97.0 test -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage --lib: core 1259 passed and 1 ignored, engine 982 passed, server 523 passed and 5 failed, storage 294 passed. On this host 5 backup_store::tests fail on every branch, because uid 65534 owns /local/home. The storage count of this command includes 4 tests that need the test-util feature of extenddb-storage, which the server's dev-dependency turns on in this build. cargo +1.97.0 test --locked -p extenddb-storage --lib alone runs and lists 290.
  • cargo +1.97.0 fmt --all -- --check is clean. cargo +1.97.0 clippy of the four crates with --all-targets -- -D warnings is clean, and so is the same command with --features extenddb-engine/backup-test-hooks. cargo +1.94.0 check of the four crates with --all-targets is clean. cargo +1.97.0 test -p extenddb-wasm-adapter: the 3 unit tests pass, and the parity test passes over the 281 cases of the corpus. The clippy step of the WebAssembly workflow, run on this branch, is clean.
  • On the first revision of this PR, a control reverted the engine's text mapping and the core's region and short id rules. Then 5 of the changed tests failed. On 125391403, without its partition check, an_arn_in_another_partition_is_a_validation_exception failed at the aws-cn row with the upper-case id. At e3672395cb, with len() in place of chars().count() in the short id rule of check_backup_arn, malformed_arn_is_a_validation_exception_with_the_services_text fails at éé.
  • Against ExtendDB on SQLite built from this head, 215 wire tests passed: tests/test_backup_restore_fidelity.py 37, tests/test_continuous_backups.py 9, tests/test_authz_cross_account.py 19, tests/test_authz_resource_arn.py 49, tests/python/test_nul_table_name_fields.py 52, tests/python/test_nul_arn_shapes.py 48 and tests/python/test_warm_throughput_backup.py 1. The 46 tests of tests/test_backup_job.py skipped, because they start their own server from EXTENDDB_BINARY and these runs did not set it. The head of fix(server): refuse a BackupArn or TableName of another JSON type first #1291, 06402b5de0, does not have this change. Against a server built from it, test_backup_and_table_names_are_validated fails at the first new row. There DescribeBackup with no BackupArn gets the null text, where the test expects Invalid Backup ARN. pytest --collect-only -q collects 7301 tests in tests/ and 820 in tests/python, with no error.
  • The two aws-cn requests of the table with the upper-case id went to a SQLite server built from 2fda6a911 and got NV, as on DynamoDB.

Line counts: production +134 -72, tests +269 -208, docs +5 -4.

This PR adds a conflict with #1328, which fixes #617, in crates/core/src/backup_format/layout.rs, crates/engine/src/backup/tests.rs, crates/engine/src/backup_requests.rs, docs/differences-from-dynamodb.md, docs/dynamodb-limits.md and tests/test_backup_restore_fidelity.py. The base of this PR merges with #1328 with no conflict. The PR that merges second takes both changes. #1358, #1359, #1365, #1367 and #1373 contain the first commit of this PR. This head adds a conflict with them in crates/engine/src/backup/tests.rs, and with #1373 in the two docs files as well. This PR adds no conflict with main.

Not in this PR:

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

RestoreTableFromBackup, DescribeBackup and DeleteBackup give an absent or malformed BackupArn other texts than before, as the table in Why shows. A restore answers the account and the Invalid Backup ARN shapes of its BackupArn before its TargetTableName. A client that matches on the old texts sees the new ones. A well-formed BackupArn of the caller's account gets the same answer as before.


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.

ExtendDB answered a RestoreTableFromBackup with no BackupArn with the
Value null text, and one whose BackupArn is not an ARN with "Invalid
Request: BackupArn is not valid". When the server refused the
TargetTableName, it answered the name first. DescribeBackup and
DeleteBackup gave an absent or empty BackupArn the same two texts.

DynamoDB answers each of these with "Invalid Backup ARN", before the
TargetTableName. Measured in us-east-1 on 21 Nov 2026 with signed
requests, each sent twice with the same answer. It gives that text to
a string that is not a backup ARN of the right shape, to a table
segment outside the name pattern, to an ARN over 1024 characters and
to a backup id of fewer than 3 characters. It gives "Invalid Request:
BackupArn is not valid" to a backup id of 3 characters or more that is
not one, a control character in it included, and to an ARN of the
caller's account in another partition, and answers that text after the
TargetTableName. DescribeBackup and DeleteBackup give it to a
region outside [a-z0-9-] too; a restore answers such a region with its
cross-region text, which ExtendDB does not give. An ARN whose account
field is not the caller's, an empty one or an S3 ARN included, is
AccessDeniedException before either text. An id of 14 digits and 8 hex
digits in upper case is BackupNotFoundException.

The BackupArn parser now sorts its refusals into those classes, with a
class for the region. The engine reads an absent BackupArn as an empty
one, compares the account field first, and a restore answers the id
and the region after the TargetTableName. When the server refuses a
restore's TargetTableName, it answers the account and the shape of the
BackupArn first. An upper-case id is answered as not found without a
lookup, since no build issues one. The ListBackups cursor gets the new
class texts; its account is still compared after its shape.

Fixes #1272.
#1009 moved canonical_backup_arn, check_backup_arn,
BACKUP_ARN_NOT_VALID and required_str from backup.rs to
backup_requests.rs, which compiles on every target.

Conflicts:

- backup.rs: the block of those helpers, which main removed. This
  merge drops the block and makes the change of this branch in
  backup_requests.rs. There, check_backup_arn maps each BackupArnError
  through backup_arn_refusal and checks the partition with
  check_partition. Both helpers are crate-visible, and backup.rs
  imports them in place of check_backup_arn, which it no longer calls.
  The doc of BACKUP_ARN_NOT_VALID names the region and the backup id.
- backup.rs: the doc of the restore steps, which
  fix/1136-restore-override-index-name rewrapped. This merge keeps the
  words of this branch with the new line breaks.
- lib.rs: the pub use backup::{...} list. This merge keeps main's list
  and adds check_restore_backup_arn to it.
- table_name_gate.rs: the doc of the restore target test, where
  fix/1245-restore-name-after-account added 25 Nov to the dates. This
  merge keeps both changes.
RestoreTableFromBackup, DescribeBackup and DeleteBackup answered
BackupNotFoundException to an ARN of the caller's account in another
partition with an upper-case backup id. The id was 14 digits, a hyphen
and 8 hex digits in upper case. DynamoDB answers ValidationException
"Invalid Request: BackupArn is not valid" to it, measured in us-east-1
on 25 Nov 2026 for aws-cn on RestoreTableFromBackup and DescribeBackup.
Each request went out twice.

The not-found answer for such an id now applies only in the partition
that the server serves. In another partition the id gets the text of
the partition, which a restore gives after its TargetTableName. The doc
of BackupArnError::Id in core names the not-found answer and its
partition.
The BackupArn rows of docs/differences-from-dynamodb.md and
docs/dynamodb-limits.md gave the old split of the two texts. They now
give the classes that DynamoDB answers, as this branch answers them,
and the order of a restore against its TargetTableName. The ExtendDB
column names the measured cases that still differ: #1326, #617 and
#1354.

The README lists the checks that the WebAssembly build does not make.
It now names the account and shape checks of the BackupArn that the
server makes for a restore whose TargetTableName it refuses.
The merge of main brought the parity corpus of the WebAssembly build
and its README section. Three cases and one README sentence held the
texts that the engine gave before this branch. These requests now get
"Invalid Backup ARN". They are a ListBackups cursor that is not an ARN,
a DescribeBackup BackupArn that is not a backup ARN, and a
DescribeBackup with no BackupArn. The native parity test failed at the
first of these cases.

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

This branch no longer merges with main. Since #1521, main keeps the WebAssembly section in docs/webassembly.md, and a merge of this head with main aff626e conflicts in README.md. The conflict starts at #1284, but this PR adds three README edits of its own in that section: the DescribeBackup text ("Invalid Backup ARN"), the RestoreTableFromBackup row of table names, and the new BackupArn kind row. I think they need to move to docs/webassembly.md. With main's README taken, the merged tree builds, clippy with warnings as errors and fmt are clean, the core, engine, server and storage lib tests pass, the wasm adapter parity test passes natively, and the six wire files from the description pass on SQLite. So the description's "This PR adds no conflict with main" no longer holds.

CI has not finished on this head. The test aggregate of the Test workflow and the aggregate jobs of the three integration workflows were cancelled on 25 Nov before a runner took them, so the shard checks never ran. The wasm job fails on the Instant type error that #1482 fixed on main, so the wasm32 build of the three changed corpus cases has not run. Could you merge main, or rebase the stack, and rerun CI?

The headline rows of the description have no wire test. Of the wire files you list, only test_backup_arn_shapes_the_service_refuses_and_trims fails against #1291. An absent or null BackupArn (Invalid Backup ARN), the upper case id (BackupNotFoundException), an S3 ARN on a restore (Access is denied) and the order of x and bad against the name ab are pinned only by engine and gate unit tests. I sent them to a SQLite server built from this head and they give the answers in your table. A wire row for each in tests/test_backup_restore_fidelity.py would run them through the server on all four backends. I think that is worth adding.

Two questions on cases the description does not measure. If I change backup_id.chars().count() < 3 to backup_id.len() < 3, every core and engine test still passes, so no test decides whether the rule counts characters or bytes. On this head an id of éé gets "Invalid Backup ARN" and ééé gets "Invalid Request: BackupArn is not valid". Has DynamoDB been sent a non ASCII id of one or two characters? The same question for a mixed case id such as 01791976431438 followed by 73D8d5bc, which this head answers with BackupNotFoundException because the check lower cases the whole ARN. The description measures only the all upper case id.

The description says "storage 291 passed". I count 290 storage lib tests on this head, both run and listed. The #1328 conflict list also looks out of date: this head conflicts with the current head of #1328 in crates/engine/src/backup_requests.rs as well, and #1291 now merges with #1328 with no conflict.

I will approve once the README lines are in docs/webassembly.md with main merged, CI is green on that tree, and the headline rows have wire tests.

The parent branch now contains main at b3510a9.

Conflict in README.md: #1521 moved the WebAssembly section of README.md
to docs/webassembly.md. This merge keeps main's README.md. It makes the
three README edits of this branch in docs/webassembly.md. They are the
DescribeBackup text "Invalid Backup ARN", the RestoreTableFromBackup
row of the table names check, and the new BackupArn kind row.
The description's headline rows had only engine and gate tests. The
wire table of test_backup_and_table_names_are_validated now sends an
absent and a null BackupArn on DescribeBackup, DeleteBackup and
RestoreTableFromBackup. It also sends an upper-case backup id, an S3 ARN,
and the BackupArns x and bad with the target name ab. DynamoDB gave
these answers on 3 Dec 2026.

The engine table of malformed ARNs gets three ids that count the
length in characters, which no test decided before. Two U+00E9 and one
U+20AC are short. Three U+00E9 are not an id. It also gets an id in
mixed case, which is not found, as the upper-case id is.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

  • The README lines: 0ee6520 merges the new head of fix(server): refuse a BackupArn or TableName of another JSON type first #1291, which contains main at b3510a9. It keeps the README of main and makes the three README edits of this branch in docs/webassembly.md. They are the DescribeBackup text, the RestoreTableFromBackup row of table names and the BackupArn kind row. The head merges with main with no conflict, and CI runs on that tree after the push.
  • The wire rows: e367239 adds them to the table of test_backup_and_table_names_are_validated. They are an absent and a null BackupArn on DescribeBackup, DeleteBackup and RestoreTableFromBackup (Invalid Backup ARN). The others are the upper-case id (BackupNotFoundException with the ARN as sent), an S3 ARN (Access is denied), and x and bad with the target ab. DynamoDB gave each of these answers on 3 December 2026. Against a server built from the new head of fix(server): refuse a BackupArn or TableName of another JSON type first #1291, the test fails at the first new row, DescribeBackup with no BackupArn.
  • Characters or bytes: characters. On 3 December 2026 DynamoDB answered the ids é (2 bytes), éé (4 bytes) and € (3 bytes) with Invalid Backup ARN, and ééé with Invalid Request: BackupArn is not valid. The engine table of malformed ARNs now has éé, € and ééé. With len() in place of chars().count(), it fails at éé.
  • Mixed case: DynamoDB answered 01791976431438-73D8d5bc with BackupNotFoundException and the ARN as sent, on DescribeBackup and on a restore. This head gives the same answer, and the engine table has that row too.
  • The storage count: both numbers are right for their commands. The description counts the storage tests of one cargo test of the core, engine, server and storage crates. In that build the server's dev-dependency turns on the test-util feature of extenddb-storage, so the storage lib also compiles the tests that need it. At the reviewed head that is one test, key_tests::status::the_backend_check_passes_on_the_fake_catalog, so the 291 there is your 290 and that test. At the new head, main's fix(auth): read a role session's policy and tags by its access key #1523 adds the 3 tests of session_data_conformance, which need the feature too. The four-crate command runs 294 storage tests, and cargo test -p extenddb-storage --lib alone runs and lists 290. The description now gives both numbers.
  • fix(backup): strip only one trailing line terminator from a backup ARN #1328: at the new head this PR conflicts with the head of fix(backup): strip only one trailing line terminator from a backup ARN #1328 (49bd69e) in crates/core/src/backup_format/layout.rs, crates/engine/src/backup/tests.rs, crates/engine/src/backup_requests.rs, both docs files and tests/test_backup_restore_fidelity.py. The head of fix(server): refuse a BackupArn or TableName of another JSON type first #1291 merges with it with no conflict. The description now says so.

@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 README edits are in docs/webassembly.md now, main's README is untouched, and the head merges with current main with no conflict. Every check on e367239 is green, including the four gates that were cancelled before and the wasm job. The conflict list for #1328 is right: this head conflicts with 49bd69e in crates/engine/src/backup_requests.rs, both docs files and tests/test_backup_restore_fidelity.py, and #1291 merges with it cleanly.

The wire rows for the BackupArn texts are in test_backup_and_table_names_are_validated. On a SQLite build of this branch with current main they pass, and against a build of #1291 the test fails at the first new row, DescribeBackup with no BackupArn.

Characters against bytes: your measurements settle it. With len in place of chars().count() the engine test fails at the e acute pair, as you say. On the wire this head gives Invalid Backup ARN for ids of one or two characters (two e acute, the euro sign, one or two emoji) and Invalid Request: BackupArn is not valid from three characters on, with no server error.

Mixed case: DescribeBackup, DeleteBackup and a restore answer BackupNotFoundException with the ARN as sent for a real id with some letters in upper case, and the real backup stays available. The row is in the engine table.

The storage numbers are explained. I get 290 with the lib command and did not run the four crate command.

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