Skip to content

fix(engine): check a restore's TargetTableName with the restore's rules - #1247

Open
LeeroyHannigan wants to merge 6 commits into
fix/1136-restore-override-index-namefrom
fix/1224-restore-target-name
Open

LeeroyHannigan wants to merge 6 commits into
fix/1136-restore-override-index-namefrom
fix/1224-restore-target-name

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changes since the last review

  • 864140c353 merges fix(engine): check the IndexName of a restore's index override #1225's new head 26dcbe1d73, which contains main at b3510a93ee. The merge has no conflict, and the lines this PR changes stay the same.
  • 460ac61c82 adds a_restore_target_name_is_checked_against_the_deployments_bounds to crates/engine/src/backup/tests.rs. It runs restore_table_from_backup with [limits] bounds of 5 and 20. The targets abcd and 21 x characters get the length text with those bounds, and the restore reads no backup. Before, the engine tests passed with table_name_bounds(limits) replaced by (3, 255) in the restore. Now this test fails.
  • The description gives DynamoDB's answers of 3 December 2026 for the target ab with a bad BillingModeOverride and with no BackupArn. It also gives the test runs at the new head.

What

RestoreTableFromBackup checked TargetTableName with CreateTable's check, so most bad names got CreateTable's texts at tableName. It now checks the name with the restore's own check, as DynamoDB does:

  • A name whose length in UTF-16 code units is outside 3 to 255 gets TableName must be at least 3 characters long and at most 255 characters long.
  • A name within those bounds is then checked against the model's constraints at targetTableName, which count characters.
  • An absent name gets The parameter 'TableName' is required but was not present in the request.

The check is the one that SourceTableName of RestoreTableToPointInTime used, in crates/engine/src/backup_requests/pitr.rs. Its new name is check_restore_table_name. It now takes the member path, and it counts the length in UTF-16 code units, where it counted characters. The measurements of SourceTableName show the same count.

The server's table name check in crates/server/src/table_name_gate.rs runs before authorization and refuses a name outside the pattern. For a TargetTableName, it now gives the answer of check_restore_table_name, with the bounds 3 and 255. The set of names it refuses does not change, so a name with U+0000 still never reaches the authorization lookups. A deployment can set other table name bounds under [limits]. There the server's answer still names 3 and 255, where the engine checks the deployment's bounds. #992 covers the fixed bounds of the server's check, this answer among them.

The server's check passes an empty TargetTableName and one that starts with arn: and has no U+0000. It answers every other name outside the pattern. The engine refuses an empty name for its length, so only an arn: name can get the engine's pattern clause at targetTableName. No test sends one, because DynamoDB's answer to it for a caller with the target's permissions is not measured. On 25 November 2026, a caller without dynamodb:Scan on table/<TargetTableName> got AccessDeniedException for it, so DynamoDB checks the permissions on that resource first.

The base of this PR is #1225, which changes the same step of the restore.

Why

DynamoDB's answers, measured in us-east-1 on 20 November 2026. Each request went out twice and got the same answer both times. Each BackupArn names a backup that does not exist. LENGTH stands for TableName must be at least 3 characters long and at most 255 characters long.

TargetTableName DynamoDB ExtendDB on #1225
ab LENGTH 1 validation error detected: with the length clause at tableName
an empty string LENGTH 1 validation error detected: with Member must have length greater than or equal to 1 at tableName
a* LENGTH 2 validation errors detected: with the length clause and the pattern clause at targetTableName
256 characters LENGTH 1 validation error detected: with Member must have length less than or equal to 255 at tableName
one U+1F600 LENGTH the two clauses at targetTableName
two U+00E9 LENGTH the two clauses at targetTableName
128 U+1F600 LENGTH the pattern clause at targetTableName
ab, with a GSI override or an LSI override LENGTH the length clause at tableName
absent The parameter 'TableName' is required but was not present in the request 1 validation error detected: Value null at 'targetTableName' failed to satisfy constraint: Member must not be null
two U+1F600 the two clauses at targetTableName the same
a b the pattern clause at targetTableName the same
64 U+1F600 the pattern clause at targetTableName the same
255 characters BackupNotFoundException BackupNotFoundException

With this change, ExtendDB answers each of the 14 rows as DynamoDB does.

Fixes #1224

Merge of 25 November

On 25 November #1137 merged main, where #1009 moved crates/engine/src/backup/pitr.rs to crates/engine/src/backup_requests/pitr.rs. So this branch conflicted with #1137 and with main in crates/engine/src/backup.rs and crates/engine/src/lib.rs. 2964ee548 merges #1225's head and resolves them:

  • Git applies the changes of this PR to pitr.rs and pitr/tests.rs at their new paths.
  • backup.rs drops its pub use pitr::... lines, as main did, and imports pitr and table_name_bounds from backup_requests.
  • lib.rs keeps the pub use backup::{...} list of main and re-exports check_restore_table_name from backup_requests, beside refuse_point_in_time_recovery.
  • In backup_requests.rs, the pitr module and table_name_bounds become crate-visible, and so does table_name_member in pitr.rs. A crate-visible re-export of table_name_member would be an unused import in the WebAssembly build, which does not compile backup.rs.

At this head, the conflicts with other open PRs:

Testing done

At 460ac61c82, 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 521 passed and 5 failed, storage 294 passed. On this host 5 backup_store::tests fail on every branch, because uid 65534 owns /local/home.
  • 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 279 cases of the corpus. The clippy step of the WebAssembly workflow, run on this branch, is clean.
  • The new rows are in the existing tables of pitr/tests.rs, backup/tests.rs and the table name check's tests. With the change reverted, they fail.
  • With table_name_bounds(limits) replaced by (3, 255) in the restore, a_restore_target_name_is_checked_against_the_deployments_bounds fails at abcd, which then gets BackupNotFoundException.
  • Against ExtendDB on SQLite built from this head, tests/test_backup_restore_fidelity.py passed 37 tests and tests/test_continuous_backups.py passed 9. In the first file, 13 rows of the cases table are new. The test that holds them fails against a server built from e56f70205, the fix(engine): check the IndexName of a restore's index override #1225 commit that this branch started from. It fails first on ab with a GSI override. pytest --collect-only -q collects 7301 tests in tests/ and 820 in tests/python, with no error.
  • A test ran the server's name check on every Unicode scalar value in 10 name templates, 10,026,807 names in all. No name that the server refused before passes now, and the server refuses no name that passed before. This ran on 9444edca4. The later commits changed only comments in table_name_gate.rs.
  • On SQLite and on PostgreSQL, a TargetTableName with U+0000, an ARN among them, got HTTP 400 ValidationException, and the server log had no internal error. This also ran on 9444edca4.

Line counts: production +61 -27, tests +88 -11.

Not in this PR, each in an open issue:

For a SourceTableName of two U+1F600, DynamoDB lists the two clauses in either order, and check_restore_table_name lists the length clause first. ExtendDB refuses every RestoreTableToPointInTime before this check, so no answer shows it.

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

A RestoreTableFromBackup TargetTableName that DynamoDB refuses gets DynamoDB's text, as the table in Why shows, and an absent one gets The parameter 'TableName' is required but was not present in the request. A client that matches the old texts sees the new ones. The set of target names that ExtendDB refuses does not change.


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.

RestoreTableFromBackup checked TargetTableName with CreateTable's
check. So a name of two characters got CreateTable's member text, and
an absent name got the text for a null member. DynamoDB answers with
the restore's own texts.

DynamoDB first counts the name's length in UTF-16 code units. A length
outside 3 to 255 is "TableName must be at least 3 characters long and
at most 255 characters long". A name within those bounds is then
checked against the model's constraints at targetTableName, which count
characters. An absent name is "The parameter 'TableName' is required
but was not present in the request".

So ab, an empty name, a*, 256 characters, one U+1F600, two U+00E9 and
128 U+1F600 get the length text. Two U+1F600 and 64 U+1F600 get the
constraint text. The SourceTableName of RestoreTableToPointInTime counts
its length the same way.

The restore now checks TargetTableName with the check of
SourceTableName, renamed check_restore_table_name. It takes the member
path and counts the length in UTF-16 code units, where it counted
characters. The server's name check gives the same answer for a target
name outside the pattern.

Measured in us-east-1 on 20 Nov 2026.

Fixes #1224.
…et-name

#1009 moved crates/engine/src/backup/pitr.rs to
crates/engine/src/backup_requests/pitr.rs, and the pitr re-exports from
backup.rs to backup_requests.rs. Git applies the pitr.rs and
pitr/tests.rs changes of this branch at the new paths.

Conflicts:

- backup.rs: the pitr re-exports at the end of the file, which main
  removed. This merge drops them.
- lib.rs: the pub use backup::{...} list. This merge keeps main's
  list. lib.rs now re-exports check_restore_table_name from
  backup_requests, beside refuse_point_in_time_recovery.

The restore in backup.rs calls pitr::table_name_member,
pitr::check_restore_table_name and table_name_bounds, which are now in
backup_requests. So the pitr module, table_name_member and
table_name_bounds become crate-visible, and backup.rs imports pitr and
table_name_bounds from backup_requests. A crate-visible re-export of
table_name_member would be an unused import in the WebAssembly build,
which does not compile backup.rs.
The module doc of table_name_gate.rs listed targetTableName among the
locations of the bare-name sentence. A RestoreTableFromBackup
TargetTableName gets the answer of check_restore_table_name, which a
later item of the list describes. The bare-name list now gives
targetTableName and sourceTableName as members of
RestoreTableToPointInTime.
check_restore_table_name is public and returns a Result, and
clippy::missing_errors_doc asks for the section.

@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 tests do not pin the deployment's table name bounds for the restore target. In crates/engine/src/backup.rs, when I replaced table_name_bounds(limits) with (3, 255), the engine lib tests (934) and the server lib tests (519) all still passed. The restore tests use the default limits, and the one bounds test calls check_restore_table_name with (5, 10) directly. On main the target name followed the configured bounds, so this would be a regression nobody sees. I measured the current code with min 5 and max 20 on SQLite and it behaves as the description says ("abcd" gets "at least 5 characters long and at most 20"). Could you add an engine test that runs restore_table_from_backup with those limits and a four character target?

The wasm check fails at this head on web_time::Instant against std::time::Instant in crates/core/src/metrics/collector.rs:60, which #1482 fixed on main. mongodb-rust fails in the auth crate on secmem::tests::init_refuses_under_a_low_memlock_limit_then_starts_unlocked, and mongodb-integration fails behind it. That secmem test failed on three other runs on 25 Nov and main's later MongoDB runs pass. I merged main 222d80a into this head locally: no conflict, the engine, server and core lib tests pass, and the two wire files plus my probes pass on SQLite. Could you merge main so CI runs on that tree?

A question on the order. With the target "ab" and an invalid BillingModeOverride, ExtendDB answers only the billingModeOverride enum fault, and with no BackupArn it answers the backupArn null fault. With the target "a*" and the same two requests it answers the length text, because the server check runs first. The description measured "ab" against an override name and another account's BackupArn. Has DynamoDB been asked "ab" with an invalid BillingModeOverride, and with no BackupArn? If it answers the name first, I think #1245 covers more than names outside the pattern.

I will approve once the bounds test is in and CI is green on a branch with main merged.

…et-name

The parent branch now contains main at b3510a9.
…unds

The restore tests used the default limits, and the one bounds test
called check_restore_table_name with (5, 10) directly. With
table_name_bounds(limits) replaced by (3, 255) in the restore, every
engine test passed. The new test runs restore_table_from_backup with
the bounds 5 and 20 and the names abcd and 21 x characters.
@LeeroyHannigan

Copy link
Copy Markdown
Collaborator Author

@navareamol

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

No open points on this PR at 460ac61.

The bounds test is in. a_restore_target_name_is_checked_against_the_deployments_bounds runs restore_table_from_backup with bounds of 5 and 20 and expects the length text with those bounds and no backup read. With table_name_bounds(limits) replaced by (3, 255) in the restore it fails, because abcd then reaches the backup lookup. I also ran the server on SQLite with min 5 and max 20: abcd, an empty name and 21 x answer "at least 5 characters long and at most 20", and abcde and 20 x restore. The server's own check still names 3 and 255 for a name such as a*, which is #992.

CI is green on this head, 66 of 66 checks including wasm, mongodb-rust and mongodb-integration, and main as it is now merges into it with no conflict. The engine lib tests (982) and the server lib tests (526) pass, and so do tests/test_backup_restore_fidelity.py and tests/test_continuous_backups.py. The set of names the server refuses is unchanged over 13.3 million names.

On the order, your measurements answer my question. With no BackupArn, the BackupArn comes first in DynamoDB and in ExtendDB, and only the text differs (#1272). With ab and BOGUS, DynamoDB answers the length text and ExtendDB answers the enum fault, because the restore parses the override values at step 1, before the target length. That is the first row of #1271. The server's pattern check passes ab, so #1245 does not cover it, as you say.

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