Repository navigation
fix(engine): answer a missing or malformed BackupArn as DynamoDB does - #1327
LeeroyHannigan wants to merge 7 commits into
Conversation
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
left a comment
There was a problem hiding this comment.
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.
|
navareamol
left a comment
There was a problem hiding this comment.
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.
Changes since the last review
0ee652026fmerges fix(server): refuse a BackupArn or TableName of another JSON type first #1291's new head06402b5de0, which containsmainatb3510a93ee. It has one conflict, inREADME.md: docs(readme): lead with a first request, move WebAssembly to its own page #1521 moved the WebAssembly section of the README todocs/webassembly.md. The merge keeps the README ofmainand makes the three README edits of this PR indocs/webassembly.md. These are theDescribeBackuptextInvalid 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 oftest_backup_and_table_names_are_validatedsends the headline rows of the table below. They are an absent and a nullBackupArnon the three operations, an upper-case backup id, an S3 ARN, and theBackupArnvaluesxandbadwith the targetab. 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.What
RestoreTableFromBackup, DescribeBackup and DeleteBackup now answer an absent or malformed
BackupArnwith DynamoDB's texts, in DynamoDB's order.Invalid Backup ARNis the answer to an absent, null or emptyBackupArn, 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 validis 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-].AccessDeniedExceptionandAccess is deniedbefore 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).BackupNotFoundExceptionin theawspartition. In another partition it getsInvalid Request: BackupArn is not valid.A restore answers the account and the
Invalid Backup ARNshapes before itsTargetTableName. It answers the backup id, the region and the partition after the name.The changes:
check_backup_arnincrates/core/src/backup_format/layout.rssorts its refusals into these classes. The new classBackupArnError::Regionholds a region outside[a-z0-9-]. The set of ARNs that the parser accepts does not change.crates/engine/src/backup.rs,backup_arn_memberreads an absentBackupArnas an empty one and compares the account field first.backup_arn_refusalincrates/engine/src/backup_requests.rsmaps each class to its text, for theBackupArnand for the ListBackups cursor.check_restore_backup_arngives the checks that a restore makes before its name. Whencrates/server/src/table_name_gate.rsrefuses a restore'sTargetTableName, it calls this function first.awspartition the engine answers one as not found without a lookup.docs/differences-from-dynamodb.md,docs/dynamodb-limits.mdanddocs/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
ExclusiveStartBackupArngets 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-cnrow 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.Invalid Backup ARN.Invalid Request: BackupArn is not valid.1 validation error detected: Value null at 'backupArn' failed to satisfy constraint: Member must not be null.TableName must be at least 3 characters long and at most 255 characters long.AccessDeniedExceptionwithAccess is denied.BackupNotFoundException.BackupArnor a null oneBackupArn""or a table segment of 1000 charactersBackupArnx,arn:,not-an-arn,arn:aws:dynamodbor an ARN with a field missingxcharactersbad01791976431438-*, or one with 7 or 9 hex digits, agor anxin the digitsaws-cnpartition (25 November 2026)a*a*BackupArn, target namea*BackupArnx, target nameabbad, target nameabaws-cnpartition, target nameababOn 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 id01791976431438-73D8d5bcin 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 noBackupArnor a null one on the three operations, the upper-case id, the S3 ARN, andxandbadwithab. This head gives the same answers.Both trees already answer AD for another account and for an empty account field. For the
aws-cnrow 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 and5aa21734bgives it to 66. No request that5aa21734banswers 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 and5aa21734bto 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 5backup_store::testsfail on every branch, because uid 65534 owns/local/home. The storage count of this command includes 4 tests that need thetest-utilfeature ofextenddb-storage, which the server's dev-dependency turns on in this build.cargo +1.97.0 test --locked -p extenddb-storage --libalone runs and lists 290.cargo +1.97.0 fmt --all -- --checkis clean.cargo +1.97.0 clippyof the four crates with--all-targets -- -D warningsis clean, and so is the same command with--features extenddb-engine/backup-test-hooks.cargo +1.94.0 checkof the four crates with--all-targetsis 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.125391403, without its partition check,an_arn_in_another_partition_is_a_validation_exceptionfailed at theaws-cnrow with the upper-case id. Ate3672395cb, withlen()in place ofchars().count()in the short id rule ofcheck_backup_arn,malformed_arn_is_a_validation_exception_with_the_services_textfails atéé.tests/test_backup_restore_fidelity.py37,tests/test_continuous_backups.py9,tests/test_authz_cross_account.py19,tests/test_authz_resource_arn.py49,tests/python/test_nul_table_name_fields.py52,tests/python/test_nul_arn_shapes.py48 andtests/python/test_warm_throughput_backup.py1. The 46 tests oftests/test_backup_job.pyskipped, because they start their own server fromEXTENDDB_BINARYand 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_validatedfails at the first new row. There DescribeBackup with noBackupArngets the null text, where the test expectsInvalid Backup ARN.pytest --collect-only -qcollects 7301 tests intests/and 820 intests/python, with no error.aws-cnrequests of the table with the upper-case id went to a SQLite server built from2fda6a911and 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.mdandtests/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 incrates/engine/src/backup/tests.rs, and with #1373 in the two docs files as well. This PR adds no conflict withmain.Not in this PR:
\n(BackupArn with leading or trailing whitespace resolves; DynamoDB accepts only one trailing line terminator #617).Messageof AccessDeniedException (UpdateTable with a table ARN of an account that does not exist answers AccessDeniedException with another __type and message key than DynamoDB #1116).Invalid Backup ARN(DescribeBackup and DeleteBackup answer Invalid Backup ARN to an ARN of another account that is not a backup ARN, where DynamoDB answers AccessDeniedException #1354).Access is denied, where DynamoDB answersInvalid Backup ARN(DescribeBackup and DeleteBackup answer Invalid Backup ARN to an ARN of another account that is not a backup ARN, where DynamoDB answers AccessDeniedException #1354).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
Breaking changes
RestoreTableFromBackup, DescribeBackup and DeleteBackup give an absent or malformed
BackupArnother texts than before, as the table in Why shows. A restore answers the account and theInvalid Backup ARNshapes of itsBackupArnbefore itsTargetTableName. A client that matches on the old texts sees the new ones. A well-formedBackupArnof 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.