Repository navigation
fix(engine): answer a ListBackups cursor with DynamoDB's texts - #1373
LeeroyHannigan wants to merge 7 commits into
Conversation
ListBackups checked its ExclusiveStartBackupArn with the BackupArn
parser of DescribeBackup. It gave that parser's texts and compared the
account before the region. DynamoDB checks the cursor in the order
below. Every refusal is a ValidationException.
1. The length as sent, 37 to 1024 characters. The text is the
model's clause at 'exclusiveStartBackupArn' (MIN or MAX below).
2. The structure, else "Invalid Backup ARN" (IBA). It needs six
fields, a partition and a resource of table/<name>/backup/<id>.
The name has 3 to 255 characters of [a-zA-Z0-9_.-], and the id
has 3 characters or more.
3. A backup ARN, else "Invalid Request: The supplied
ExclusiveStartBackupArn is not a valid backup arn" (NOT-BACKUP).
It needs the partition aws, the service dynamodb and an account
that is not empty. The region is not empty and has no slash or
"..". The id has 14 digits, "-" and 8 hex digits in either case.
4. The region, else "Invalid Request: The supplied
ExclusiveStartBackupArn does not match the region" (REGION).
5. The account, of any characters, else the same text with
"account" (ACCOUNT).
6. With TableName, the table, else the same text with "table name
predicate".
Measured in us-east-1 on 6, 21 and 22 Nov 2026 with ListBackups, each
request twice with the same answer. OTHER is another account, and NV
is "Invalid Request: BackupArn is not valid". The unit test's table
holds the other measured cursors.
cursor DynamoDB before
the first 36 characters MIN IBA
950 x after the id MAX IBA
service s3 NOT-BACKUP IBA
empty account NOT-BACKUP IBA
partition aws-cn NOT-BACKUP NV
id bad-id NOT-BACKUP NV
U+0000 at the end NOT-BACKUP NV
table segment ab IBA 200
region US-EAST-1 REGION NV
account abcdefghijkl ACCOUNT IBA
account OTHER, region us-west-2 REGION ACCOUNT
account OTHER, id bad-id NOT-BACKUP NV
id of 14 digits and upper-case hex 200 NV
The cursor now runs the six steps in that order. The structure check
is split_backup_arn, the first half of check_backup_arn. The answers
of DescribeBackup, DeleteBackup and RestoreTableFromBackup do not
change. The length clause is length_clause, taken out of
validate_name_member_after. An id in upper-case hex is read in lower
case, so the cursor is placed by its time.
The table name bounds are the deployment's, 3 and 255 by default. A
cursor in another region or with a table segment outside the bounds
is accepted when it is a listed backup's stored ARN. That is the
LastEvaluatedBackupArn of a backup taken under an earlier
server.region or other bounds. Any other such cursor gets REGION or
IBA. Whitespace around the cursor is trimmed as before, and #1328
changes that rule.
Fixes #1315.
Fixes #907.
navareamol
left a comment
There was a problem hiding this comment.
I think the branch no longer merges with main, and the cursor code has moved. git merge-tree --write-tree against main at 92155f3 conflicts in crates/core/src/error/mod.rs, crates/engine/src/backup.rs, crates/engine/src/lib.rs and crates/engine/src/partiql/request_checks.rs. The three files other than backup.rs conflict for #1367 too, so they come from the lower branches. In backup.rs the conflict is the block that holds list_backups, list_backups_cursor, cursor_mismatch and ListBackupsCursor: main moved them to crates/engine/src/backup_requests.rs, so this change has to be applied again there. The description says git merge-tree shows no conflict with main. The CI runs are from 23 November on a tree without main's wasm, pr title and search inequality workflows, and Integration Tests passed on its second attempt (the first failed in run-postgres-storage-tests, and I cannot read that log any more). Could you rebase the stack on main and let CI run on the new tree?
Two checks that tests do not pin. Changing (min..=max).contains(&table.len()) to (min..max) in list_backups_cursor leaves all 468 engine backup tests green, because the table has ab and a 256 character segment but no row at 255. A row for 255 would catch it. Dropping f.account != account_id || or || other_table from the region branch also leaves every test green, and the server answers the same, because resolve only accepts an ARN that is in the listing and the listing holds only the caller's account and the TableName table. Do you want to keep them, and if so which test shows what they decide?
On a restarted server with other limits I took backups of a, ab and abc, then ran with 3 to 255. The ARN of a listed ab backup works as a cursor, but after DeleteBackup of that backup its ARN answers "Invalid Backup ARN", while the ARN of a deleted backup of an in bounds table resumes with 200. A client that pages while such a backup is deleted gets an error on its next page. Has anyone checked what DynamoDB answers for a deleted backup whose table segment is outside the bounds?
A cursor with a 13 digit id (with or without the 8 hex suffix) that names no listed backup passes the six steps and answers "ExclusiveStartBackupArn does not name a backup in this listing, and its id carries no creation time to resume from", which is not one of the six texts. The description names the 13 digit shape for 3 of the 320 cursors. Has anyone checked the DynamoDB answer for it?
I will approve once the stack is rebased on main with CI green on that tree, and the 255 character row is added.
The new head of fix/1361-segment-length holds the new heads of the five branches below it and main of 2 Dec. On main, #1009 moved ListBackups, its cursor and check_backup_arn from backup.rs to backup_requests.rs. Conflicts: - backup.rs: list_backups, list_backups_cursor, cursor_mismatch, ListBackupsCursor, canonical_backup_arn and check_partition, which main moved. The merge takes main's backup.rs and makes this branch's changes in backup_requests.rs. They are the cursor's six steps, BACKUP_ARN_BOUNDS, CURSOR_NOT_A_BACKUP_ARN, the Stored cursor, and the table name bounds that list_backups passes. check_backup_arn had one caller, the old cursor check, so the merge removes it there as this branch did, and check_partition gets its doc. The imports of the cursor move with it. - backup.rs: the doc of backup_arn_member. The merge takes the doc of fix/1361-segment-length and links the storage check_backup_arn. - backup/tests.rs: this branch removed the cursor check of the malformed ARN test, whose rows its own cursor table replaces. The merge removes it. In the doc of the partition test, the merge keeps the dates of fix/1361-segment-length and the cursor sentence of this branch. - docs/differences-from-dynamodb.md and docs/dynamodb-limits.md: the BackupArn rows. The merge takes the rows of fix/1361-segment-length and makes this branch's two sentence changes on the cursor in them.
DynamoDB gave these answers on 3 Dec 2026, each request sent twice: - An id of 256 characters or more is "Invalid Backup ARN" on DescribeBackup and on the ListBackups cursor. One of 255 characters is "Invalid Request: BackupArn is not valid" on DescribeBackup and "...is not a valid backup arn" on the cursor. split_backup_arn bounded the id at 3 characters and no more. It now refuses more than 255 characters as structure, so DescribeBackup, DeleteBackup and a restore answer such an id with "Invalid Backup ARN" too. - A cursor with an id of 13 digits, with or without the hex suffix, is "...is not a valid backup arn". Here it passed the six steps and got a text of ExtendDB's own. It now gets the service's text, unless it is a listed backup's ARN. page_backups then has no cursor without a time to refuse, and that error goes. - DynamoDB answers a cursor in another region of another account, or of another table, after a time range whose lower bound is above its upper. Here the region step refused it first. The step now defers it as it does for the caller's own ARN, so the time range comes first. The cursor table gets rows for the id of 255 and 256 characters and a table segment of 255 characters. It also gets three region fields, the two 13-digit ids and the two time range cases. The DescribeBackup table gets the id rows. The docs rows give the id bound, the region rule as the code applies it, and the answer to an id of an earlier build.
The new head of fix/1361-segment-length gives the service's answer for a padded backup ARN of another account in the BackupArn row of docs/differences-from-dynamodb.md. The row named an issue number there. Conflict: - docs/differences-from-dynamodb.md: the BackupArn row. The merge keeps the row of this branch with that one sentence changed.
The comment named an issue number that does not exist yet. It now says which prefix the service's text has and this build does not give.
The new head of fix/1361-segment-length builds one row of the restore order test with std::slice::from_ref, which clippy asks for. The merge has no conflict.
…ses them The cursor no longer calls canonical_backup_arn or check_partition, so the WebAssembly build, which compiles backup_requests.rs and not backup.rs, refused them as dead code. They move back to backup.rs, the one module that calls them. The parity corpus case "ListBackups with an ExclusiveStartBackupArn that is not an ARN is refused" sends the cursor "nope". The cursor checks its length first now, so the case expects the model's length clause, as DynamoDB gives it.
|
Changes since the last review
The branch is at
dcf0f776c9. These commits sit on94d1153943, the head that the review of 2 Dec 2026 read:13efe97471merges fix(engine): refuse a BackupArn table segment of a bad length #1367 at568ff4597e, which holds fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's pushed head,mainof 2 Dec and the new heads of the PRs below this one. Onmain, feat(wasm): [Add WebAssembly browser support for ExtendDB #1009 moved ListBackups, its cursor andcheck_backup_arnfromcrates/engine/src/backup.rstocrates/engine/src/backup_requests.rs. The conflicts:backup.rs:list_backups,list_backups_cursor,cursor_mismatch,ListBackupsCursor,canonical_backup_arnandcheck_partition, whichmainmoved. The merge takesmain'sbackup.rsand makes this PR's changes inbackup_requests.rs: the six steps of the cursor,BACKUP_ARN_BOUNDS,CURSOR_NOT_A_BACKUP_ARN, theStoredcursor, and the table name bounds thatlist_backupspasses.check_backup_arnhad one caller, the old cursor check, so the merge removes it there as this PR did.backup.rs: the doc ofbackup_arn_member, where the merge takes the doc of fix(engine): refuse a BackupArn table segment of a bad length #1367 and links the storagecheck_backup_arn.backup/tests.rs: this PR removed the cursor check of the malformed ARN test, whose rows its own cursor table replaces. The merge removes it. In the doc of the partition test, the merge keeps the dates of fix(engine): refuse a BackupArn table segment of a bad length #1367 and the cursor sentence of this PR.BackupArnrows ofdocs/differences-from-dynamodb.mdanddocs/dynamodb-limits.md: the merge takes the rows of fix(engine): refuse a BackupArn table segment of a bad length #1367 and makes this PR's two sentence changes on the cursor in them.5e9eca641efixes what the review found, with DynamoDB's answers of 3 December 2026:split_backup_arnrefuses a backup id of more than 255 characters as structure, beside the minimum of 3. So an id of 256 characters or more isInvalid Backup ARNon the cursor, and on DescribeBackup, DeleteBackup and a restore too....is not a valid backup arnunless it is the ARN of a listed backup. Before, it passed the six steps and got a text of ExtendDB's own.page_backupsthen has no cursor without a time to refuse, and that error goes.d5c799c1a1merges fix(engine): refuse a BackupArn table segment of a bad length #1367 ata6fc681dec. One conflict, theBackupArnrow ofdocs/differences-from-dynamodb.md, where the merge keeps the row of this PR with the one sentence of fix(server): answer the account of a BackupArn before its shape #1358 changed.e9bf48ac24: the comment of the cursor test says which prefix the service's time range text has and this build does not give.856462ea55merges fix(engine): refuse a BackupArn table segment of a bad length #1367 at9f39cea225, with no conflict.dcf0f776c9: the cursor no longer callscanonical_backup_arnorcheck_partition, so the WebAssembly build, which compilesbackup_requests.rsand notbackup.rs, refused them as dead code. They move back tobackup.rs, the one module that calls them. The parity corpus case "ListBackups with an ExclusiveStartBackupArn that is not an ARN is refused" sends the cursornope. That cursor now gets the model's length clause first, as DynamoDB gives it.What
ListBackups now checks its
ExclusiveStartBackupArnin DynamoDB's order, with DynamoDB's texts. Before, it used theBackupArnparser of DescribeBackup. It gave that parser's texts, and it compared the account before the region.These are the six steps. Each refusal is a
ValidationException.exclusiveStartBackupArn, with the value.Invalid Backup ARN. The resource istable/<name>/backup/<id>, the name is a table name, and the id has 3 to 255 characters.Invalid Request: The supplied ExclusiveStartBackupArn is not a valid backup arn. This step checks the partition, the service, a region of letters, digits and-(any case), an account that is not empty and the id shape.Invalid Request: The supplied ExclusiveStartBackupArn does not match the region.account.TableName, the table segment, else the same sentence withtable name predicate.The changes:
list_backups_cursorincrates/engine/src/backup_requests.rsruns the six steps.split_backup_arnincrates/core/src/backup_format/layout.rsis the structure half ofcheck_backup_arn, which now calls it. DescribeBackup, DeleteBackup and RestoreTableFromBackup keep their answers, except for an id of more than 255 characters, which isInvalid Backup ARNnow, where it wasInvalid Request: BackupArn is not valid.length_clauseincrates/core/src/validation/mod.rscomes out ofvalidate_name_member_after, which now calls it.This PR removes the engine's private
check_backup_arnwrapper. Its one caller was the cursor.ListBackupsCursor::OtherRegionis nowListBackupsCursor::Stored. Three kinds of cursor pass only as the stored ARN of a listed backup:Such an ARN comes from a backup taken under an earlier
server.region, other bounds or an earlier build. Any other such cursor gets the region, structure or...is not a valid backup arntext, after the time range.An id of 14 digits and 8 hex digits in upper case passes, and the cursor reads it in lower case.
The cursor sentences of two rows in
docs/differences-from-dynamodb.md, and one indocs/dynamodb-limits.md, change.Two one-line checks now have a second copy. The table segment bounds check is also in
segment_out_of_bounds. The service and empty account conditions are also incheck_backup_arn. The cursor cannot share their predicates. It accepts an account of letters and an id or region in upper case, whichcheck_backup_arnrefuses, and the two give other texts.The cursor trims whitespace as before. #1328 changes that rule, so the rows of the cursor with whitespace still differ here (see Testing done).
The base of this PR is #1367.
Fixes #1315
Fixes #907
Why
These are DynamoDB's answers, measured in us-east-1 on 6, 21 and 22 November 2026 with ListBackups. Each request went out twice and got the same answer both times. The unit test's table holds the other measured cursors.
Invalid Backup ARN....is not a valid backup arn....does not match the regionand...does not match the account.Invalid Request: BackupArn is not valid.One or more parameter values were invalid: Time range lower bound must be less than or equal to upper bound.xafter the ids3aws-cnbad-idabUS-EAST-1abcdefghijklus-west-2bad-idOn 3 December 2026 these went out in the same way. The cursor is a backup ARN of the caller's account in us-east-1 with the id
01791976431438-73d8d5bc, except for the change in the first column. The ExtendDB columns come from SQLite servers built from9f39cea225anddcf0f776c9.us_east_1,us.east-1, orus-east-1and U+0000us-west-2, account000000000000us-west-2, with theTableNameof another tableDescribeBackup with an id of 255 characters gets NV, and with 256 characters IBA, on DynamoDB and with this PR. On #1367 both get NV.
Testing done
At
dcf0f776c9, each cargo command with--locked:cargo +1.97.0 test -p extenddb-core -p extenddb-engine -p extenddb-server -p extenddb-storage --lib --no-fail-fast: core 1260 passed and 1 ignored, engine 983 passed, server 524 passed, storage 294 passed. On this host 5backup_store::testsof the server fail on every branch,mainincluded, because another user owns/local/home.cargo +1.97.0 clippyof the four crates with--all-targets -- -D warnings, the same command with--features extenddb-engine/backup-test-hooks,cargo +1.94.0 checkof the four crates with--all-targets, andcargo +1.97.0 fmt --all -- --checkare clean.cargo +1.97.0 test -p extenddb-wasm-adapter: the 3 unit tests pass, and the parity test passes all 281 cases of the corpus. The clippy step of the WebAssembly workflow is clean.tests/test_backup_restore_fidelity.py124 passed andtests/test_authz_cross_account.py19 passed.pytest --collect-only -qcollectstests/andtests/pythonwith no error. The 15 cursor and DescribeBackup requests of 3 December got DynamoDB's answers, except the prefix of the time range text. 8 of the 14 cursor and DescribeBackup requests of 25 November got DynamoDB's answers, and the other 6 are under "Not in this PR".tests/test_backup_restore_fidelity.py.5e9eca641ekept the tests and put back one old line each. The old lines were the id bound at a minimum of 3 only andmin..maxfor the table segment. The others were no deferral of a 13-digit id, and the two conditions of the region step. With each one,list_backups_cursor_must_match_the_account_region_and_tablefails.Limit1 and the returnedLastEvaluatedBackupArnlisted both, with and without a trailing\nand with and withoutTableName.Line counts at
dcf0f776c9, against #1367's head9f39cea225: production +200 -125, tests +226 -85, docs +3 -3. The test files, the parity corpus and the lines after#[cfg(test)]andmod testscount as tests, and.mdfiles as docs.git merge-treeshows no conflict withmainatc8e66fb568. This PR adds no conflict file with any of the 106 open PRs that change the files of this stack. With #1328, it adds one hunk incrates/engine/src/backup_requests.rs, a file that conflicts already: the doc comment oflist_backups_cursor, where #1328 writes its trim rule. The resolution keeps this PR's comment with #1328's trim rule. On #1328's merge, its strict xfail cursor rows for whitespace pass, so they come out.Not in this PR:
Limitoutside 1 to 100 and a cursor of a bad length are one message on DynamoDB, thelimitclause first (measured on 25 November 2026). Here thelimitclause is answered alone (ListBackups answers a Limit below 1 alone when the cursor is also too short, where DynamoDB lists both clauses #1557).Invalid Backup ARN(ListBackups counts the 1024 limit of a cursor in bytes, where DynamoDB accepts a cursor of 2-byte characters and answers its account #1558).One or more parameter values were invalid:prefix here, as onmain(ListBackups answers a reversed time range without DynamoDB's "One or more parameter values were invalid" prefix #1559).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
ListBackups answers a malformed
ExclusiveStartBackupArnwith the texts of the six steps, where it gave the texts of theBackupArnparser. It compares the region before the account. A cursor with an id of the 13-digit shape that earlier builds issued gets...is not a valid backup arnunless it is the ARN of a listed backup. DescribeBackup, DeleteBackup and RestoreTableFromBackup answer a backup id of more than 255 characters withInvalid Backup ARN, where they answeredInvalid Request: BackupArn is not valid. A client that matches on the old texts sees the new ones. Paging with theLastEvaluatedBackupArnthat ListBackups returns works 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.