Skip to content

fix(engine): answer a ListBackups cursor with DynamoDB's texts - #1373

Open
LeeroyHannigan wants to merge 7 commits into
fix/1361-segment-lengthfrom
fix/1315-list-backups-cursor
Open

LeeroyHannigan wants to merge 7 commits into
fix/1361-segment-lengthfrom
fix/1315-list-backups-cursor

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

The branch is at dcf0f776c9. These commits sit on 94d1153943, the head that the review of 2 Dec 2026 read:

  • 13efe97471 merges fix(engine): refuse a BackupArn table segment of a bad length #1367 at 568ff4597e, which holds fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's pushed head, main of 2 Dec and the new heads of the PRs below this one. On main, feat(wasm): [Add WebAssembly browser support for ExtendDB #1009 moved ListBackups, its cursor and check_backup_arn from crates/engine/src/backup.rs to crates/engine/src/backup_requests.rs. The 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 PR's changes in backup_requests.rs: the six steps of the cursor, 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 PR did.
    • backup.rs: the doc of backup_arn_member, where the merge takes the doc of fix(engine): refuse a BackupArn table segment of a bad length #1367 and links the storage check_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.
    • The BackupArn rows of docs/differences-from-dynamodb.md and docs/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.
  • 5e9eca641e fixes what the review found, with DynamoDB's answers of 3 December 2026:
    • split_backup_arn refuses a backup id of more than 255 characters as structure, beside the minimum of 3. So an id of 256 characters or more is Invalid Backup ARN on the cursor, and on DescribeBackup, DeleteBackup and a restore too.
    • A cursor with an id of 13 digits, with or without the hex suffix, gets ...is not a valid backup arn unless it is the ARN of a listed backup. Before, it passed the six steps and got a text of ExtendDB's own. page_backups then has no cursor without a time to refuse, and that error goes.
    • A request can have a time range whose lower bound is above its upper bound. DynamoDB answers that time range before a cursor in another region of another account, or of another table. The region step now defers every cursor in another region, as it did for the caller's own one, so the time range comes first.
    • The cursor table gets rows for an id of 255 and of 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 and the region rule as the code applies it.
  • d5c799c1a1 merges fix(engine): refuse a BackupArn table segment of a bad length #1367 at a6fc681dec. One conflict, the BackupArn row of docs/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.
  • 856462ea55 merges fix(engine): refuse a BackupArn table segment of a bad length #1367 at 9f39cea225, with no conflict.
  • dcf0f776c9: 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. That cursor now gets the model's length clause first, as DynamoDB gives it.
  • The description gives the new rules, the counts, the conflicts and the test runs at the new head. It lists what the review found that this PR does not change.

What

ListBackups now checks its ExclusiveStartBackupArn in DynamoDB's order, with DynamoDB's texts. Before, it used the BackupArn parser 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.

  1. The length of the value as sent, 37 to 1024 characters. The text is the model's clause at exclusiveStartBackupArn, with the value.
  2. The structure, else Invalid Backup ARN. The resource is table/<name>/backup/<id>, the name is a table name, and the id has 3 to 255 characters.
  3. A valid backup ARN, else 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.
  4. The region, else Invalid Request: The supplied ExclusiveStartBackupArn does not match the region.
  5. The account, else the same sentence with account.
  6. With TableName, the table segment, else the same sentence with table name predicate.

The changes:

  • list_backups_cursor in crates/engine/src/backup_requests.rs runs the six steps.

  • split_backup_arn in crates/core/src/backup_format/layout.rs is the structure half of check_backup_arn, which now calls it. DescribeBackup, DeleteBackup and RestoreTableFromBackup keep their answers, except for an id of more than 255 characters, which is Invalid Backup ARN now, where it was Invalid Request: BackupArn is not valid.

  • length_clause in crates/core/src/validation/mod.rs comes out of validate_name_member_after, which now calls it.

  • This PR removes the engine's private check_backup_arn wrapper. Its one caller was the cursor.

  • ListBackupsCursor::OtherRegion is now ListBackupsCursor::Stored. Three kinds of cursor pass only as the stored ARN of a listed backup:

    • a cursor in another region
    • a cursor with a table segment outside the deployment's name bounds
    • a cursor with an id of the 13-digit shape that earlier builds issued

    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 arn text, 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 in docs/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 in check_backup_arn. The cursor cannot share their predicates. It accepts an account of letters and an id or region in upper case, which check_backup_arn refuses, 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.

  • IBA is Invalid Backup ARN.
  • NOT-BACKUP is ...is not a valid backup arn.
  • REGION and ACCOUNT are ...does not match the region and ...does not match the account.
  • NV is Invalid Request: BackupArn is not valid.
  • MIN and MAX are the length clauses.
  • TIME is One or more parameter values were invalid: Time range lower bound must be less than or equal to upper bound.
Cursor DynamoDB ExtendDB on #1367 ExtendDB with this PR
the first 36 characters MIN IBA MIN
950 x after the id MAX IBA MAX
service s3 NOT-BACKUP IBA NOT-BACKUP
an empty account NOT-BACKUP IBA NOT-BACKUP
partition aws-cn NOT-BACKUP NV NOT-BACKUP
backup id bad-id NOT-BACKUP NV NOT-BACKUP
U+0000 at the end NOT-BACKUP NV NOT-BACKUP
table segment ab IBA 200 IBA
region US-EAST-1 REGION NV REGION
account abcdefghijkl ACCOUNT IBA ACCOUNT
another account and region us-west-2 REGION ACCOUNT REGION
another account and backup id bad-id NOT-BACKUP NV NOT-BACKUP
an id of 14 digits and 8 hex digits in upper case 200 NV 200

On 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 from 9f39cea225 and dcf0f776c9.

Cursor DynamoDB ExtendDB on #1367 ExtendDB with this PR
an id of 13 digits, with or without the 8 hex digits NOT-BACKUP a text of ExtendDB's own NOT-BACKUP
a table segment of 255 characters 200 200 200
an id of 255 characters NOT-BACKUP NV NOT-BACKUP
an id of 256 characters IBA NV IBA
region us_east_1, us.east-1, or us-east-1 and U+0000 NOT-BACKUP NV NOT-BACKUP
1024 characters, an id of 954 characters IBA NV IBA
region us-west-2, account 000000000000 REGION ACCOUNT REGION
region us-west-2, with the TableName of another table REGION REGION REGION
the same two, with a time range whose lower bound is above its upper bound TIME ACCOUNT, REGION the time range text without its prefix

DescribeBackup 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:

Line counts at dcf0f776c9, against #1367's head 9f39cea225: production +200 -125, tests +226 -85, docs +3 -3. The test files, the parity corpus and the lines after #[cfg(test)] and mod tests count as tests, and .md files as docs.

git merge-tree shows no conflict with main at c8e66fb568. 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 in crates/engine/src/backup_requests.rs, a file that conflicts already: the doc comment of list_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:

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

ListBackups answers a malformed ExclusiveStartBackupArn with the texts of the six steps, where it gave the texts of the BackupArn parser. 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 arn unless it is the ARN of a listed backup. DescribeBackup, DeleteBackup and RestoreTableFromBackup answer a backup id of more than 255 characters with Invalid Backup ARN, where they answered Invalid Request: BackupArn is not valid. A client that matches on the old texts sees the new ones. Paging with the LastEvaluatedBackupArn that 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.

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

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

Copy link
Copy Markdown
Collaborator Author

@navareamol

  1. The branch takes the new heads of fix(engine): refuse a BackupArn table segment of a bad length #1367 with merges. 13efe97471 merges fix(engine): refuse a BackupArn table segment of a bad length #1367 at 568ff4597e and applies this PR's cursor change again in crates/engine/src/backup_requests.rs, where main moved list_backups, list_backups_cursor, cursor_mismatch and ListBackupsCursor. d5c799c1a1 (at a6fc681dec) and 856462ea55 (at 9f39cea225) take the later fix(engine): refuse a BackupArn table segment of a bad length #1367 heads. dcf0f776c9 moves canonical_backup_arn and check_partition back to crates/engine/src/backup.rs, because the WebAssembly build compiles backup_requests.rs without backup.rs and refused them as dead code there. It also changes the parity corpus case with the cursor nope, which gets the length clause first now. git merge-tree of dcf0f776c9 with main at c8e66fb568 shows no conflict. CI runs on the new tree when the branch is pushed.
  2. 5e9eca641e adds a cursor with a table segment of 255 characters, which DynamoDB pages from with HTTP 200 (3 Dec 2026). With min..max in list_backups_cursor, the engine test fails. For the two conditions, I measured on 3 Dec 2026, each request twice, with a reversed time range. A cursor in us-west-2 of the account 000000000000 gets the time range text, and so does one of the caller's account with the TableName of another table. Without the time range, both get the region text. So the region step defers every cursor, as it does for the caller's own one. 5e9eca641e drops both conditions. With them put back, the engine test fails.
  3. DynamoDB cannot hold such a backup: its table names have 3 to 255 characters. A cursor with a segment outside them gets Invalid Backup ARN there (ab and 256 characters, 22 Nov 2026). ExtendDB gives that answer once no listed backup has the ARN, which is the rule of DescribeBackup and DeleteBackup in fix(engine): refuse a BackupArn table segment of a bad length #1367. A client that pages while such a backup is deleted gets it on the next page. The rule stays.
  4. Yes, on 3 Dec 2026, each request twice. A cursor with an id of 13 digits, with or without the 8 hex digits, gets Invalid Request: The supplied ExclusiveStartBackupArn is not a valid backup arn. 5e9eca641e gives it that text, unless it is the ARN of a listed backup, such as one that an earlier build issued. With that branch taken out, the engine tests fail.

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