Repository navigation
fix(server): refuse a restore's TargetTableName of another JSON type first - #1267
LeeroyHannigan wants to merge 6 commits into
Conversation
…first RestoreTableFromBackup read a TargetTableName of another JSON type than string as an absent member. With the caller's own BackupArn, the answer was ValidationException. With an absent, malformed or another account's BackupArn, or a bad BillingModeOverride, it was that member's error. DynamoDB answers SerializationException for a number, a boolean, an object or a list (measured in us-east-1 on 20 Nov 2026, each request twice). It answers before the checks of the value of BackupArn and of the overrides. Both treat a null as an absent member. The server now checks the member's type at the start of check_table_name_chars. That runs before every BackupArn check and before the engine reads the overrides. A member of another JSON type written before TargetTableName is answered first by the service, which this check does not follow. The text is the one the restore's other members of another JSON type get. The service's texts and its member order are #1012. Fixes #1246.
The unit test matched only the SerializationException variant, so a change to the text passed every table_name_gate test. The test now checks the text by equality. The text is ExtendDB's, and DynamoDB's texts for each JSON type belong to #1012. The test name and doc said that DynamoDB answers the target before its BackupArn. When a BackupArn of another JSON type comes first in the body, DynamoDB answers the BackupArn first. The name and doc now use the words of the module doc: before the checks of the value of BackupArn.
navareamol
left a comment
There was a problem hiding this comment.
I think the README still describes the old server check. In README.md, the section "Checks the server makes that this build does not" says "The table names and index names checks pass a name that is empty, missing or not a string", and the TargetTableName row says "the server checks the BackupArn first". With this change the server answers a TargetTableName of 5, true, {} or [] with SerializationException before the BackupArn check. I measured it on SQLite with a BackupArn of "x", one of another account and one with U+0000 in its table name. The PR updates the same sentence in the doc of check_table_name_chars. Could you update the README sentence and that row, or add a row for the new check?
Two sentences of the description do not match what I measured. It says #1291, #1327, #1353, #1358, #1359, #1365, #1367 and #1373 conflict with this head in the unit test. #1291 and #1327 already contain 6fdc2cb and merge with this head with no conflict; the other six conflict in the new test as described. It also says the text is "the form the engine writes for the restore's other members of the wrong JSON type". On the head of #1247, a GlobalSecondaryIndexOverride or SSESpecificationOverride of 5 gets that form, while a BillingModeOverride of 5 gets "Start of structure or map found where not expected: invalid type: integer 5, expected string or map" and a ProvisionedThroughputOverride of 5 gets the same with "expected struct ProvisionedThroughput". Could you adjust those two sentences?
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. The branch holds main at 5252eda and main is 14 commits ahead. I merged main 222d80a into this head locally: no conflict, the engine (979), server (527) and core (1242, 1 ignored) lib tests pass, and tests/test_backup_restore_fidelity.py plus my probes pass on SQLite. Could you merge main through the stack so CI runs on that tree?
I will approve once the README and the two description sentences match the code and CI is green on a branch with main merged.
The parent branch now contains main at b3510a9.
docs/webassembly.md said that the table names check passes a name that is not a string, and its TargetTableName row put the BackupArn check first. For a TargetTableName that is neither a string nor null, the server now answers SerializationException first. That answer comes before the BackupArn, the overrides and the accounts answer. A member types row gives the check.
|
|
One point is left on this PR at e4d210f, a comment that still says what the description no longer says. In The rest of my earlier points are resolved. The README text now lives in I ran the head on SQLite. A target of 5, 5.5, true, false, {} or [] answers SerializationException before a I will approve once the doc comment matches the description. |
… type The module doc of table_name_gate.rs said that a TargetTableName of another JSON type gets the text that the other members of the restore get. That is wrong for two of them. A BillingModeOverride or ProvisionedThroughputOverride of another JSON type gets the same prefix with the text of the parse error. The doc now gives the text of the gate and says which members get each form, as the description does.
|
@navareamol 94e2ad7 changes the module doc of The doc and the description both say "that its parse refuses", because the parse takes some of these values. On SQLite at this branch's code, a |
navareamol
left a comment
There was a problem hiding this comment.
The module doc in crates/server/src/table_name_gate.rs (lines 63 to 69) now matches the code. I built 94e2ad7 on SQLite and sent RestoreTableFromBackup with a string TargetTableName and a missing BackupArn, once for each of the six override members and each of these values: 5, 5.5, true, false, "x", {}, [], [5, 5], {"PAY_PER_REQUEST": null}, {"S": "a"} and ["a"].
For the target itself: 5, 5.5, true, {}, [] and {"S": "a"} all answer SerializationException "Start of structure or map found where not expected: TargetTableName", as the doc says.
For GlobalSecondaryIndexOverride and LocalSecondaryIndexOverride, every value that is not a list answers with the member's name, as the doc says. A list with a wrong element, [5, 5] or ["a"], answers with the parse text instead ("invalid type: integer 5, expected struct GsiInput"). The doc says "of another JSON type", and a list is the right type, so I do not count this as a mismatch.
For OnDemandThroughputOverride and SSESpecificationOverride, every value that is not an object answers with the member's name. An object, even {"S": "a"} or {"PAY_PER_REQUEST": null}, gets past the check to BackupNotFoundException.
For BillingModeOverride and ProvisionedThroughputOverride, a value the parse refuses answers with the same prefix and the parse's text: "invalid type: integer 5, expected string or map" for a billing mode of 5, and "invalid type: integer 5, expected struct ProvisionedThroughput" for a throughput of 5. A billing mode of {"PAY_PER_REQUEST": null} and a throughput of [5, 5] get past the parse to BackupNotFoundException, as you wrote, and #1106 covers them. A billing mode of "x" answers the ValidationException for the enum, as before.
The change since e4d210f is the 7 added and 3 removed comment lines of this doc and nothing else, so I did not rerun the earlier unit and wire results.
All 64 checks pass on 94e2ad7, so I approve.
Changes since the last review
94e2ad729d: the module doc ofcrates/server/src/table_name_gate.rsnow gives the text of this check, as What does. It also names the members of the restore that get each form of the text. Before, it said that the text is the one the restore's other members of another JSON type get. That is not true for aBillingModeOverrideor aProvisionedThroughputOverride.What
A RestoreTableFromBackup
TargetTableNamethat is neither a JSON string nor null now gets a SerializationException, as DynamoDB answers. This answer comes before the checks of the value ofBackupArnand of the overrides. Before this change, ExtendDB read such a value as an absent member. Some requests gotThe parameter 'TableName' is required but was not present in the request. In others an earlier check answered first: a ValidationException for an absent or malformedBackupArnor a bad override, or an AccessDeniedException for another account's backup.The check is at the start of the
RestoreTableFromBackuparm ofcheck_table_name_charsincrates/server/src/table_name_gate.rs. That function runs first inauthorize_request, ahead of the cross-account refusal and the engine. A null target still passes, so the engine answers it as an absent member, as DynamoDB does.The text is
Start of structure or map found where not expected: TargetTableName. The engine writes the same form for aGlobalSecondaryIndexOverride,LocalSecondaryIndexOverride,OnDemandThroughputOverrideorSSESpecificationOverrideof another JSON type. ABillingModeOverrideorProvisionedThroughputOverrideof another JSON type that its parse refuses gets the same prefix with the parse's own text, for exampleinvalid type: integer `5`, expected string or map. The parse takes aBillingModeOverrideobject of one key with a null value and aProvisionedThroughputOverridelist of two integers (#1106). The server crate has no helper for this text that it can call, so the gate writes it once. DynamoDB's own texts belong to #1012.The base of this PR is #1247, which changes how the restore reads
TargetTableName.Fixes #1246
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 request names a backup that does not exist in the caller's account, unless the row says otherwise. SE is SerializationException.
TargetTableNameand the other members5,5.5,true,false,{},{"S": "a"},[]or["a"]The parameter 'TableName' is required but was not present in the request5, noBackupArnValue null at 'backupArn'5,BackupArn"x"Invalid Request: BackupArn is not valid5, aBackupArnwith U+0000 in its table nameInvalid Backup ARN5, theBackupArnof another account5,BillingModeOverride"X"billingModeOverride5, after aBackupArnof{}Value null at 'backupArn'nullThe parameter 'TableName' is required but was not present in the requestWith this change, ExtendDB gives each of these requests DynamoDB's exception type.
In one case the answer no longer follows DynamoDB. When an override of another JSON type comes before the target in the body, DynamoDB answers the override's fault. ExtendDB on #1247 answered the override's fault too, and it now answers the target's. This holds for
GlobalSecondaryIndexOverride,LocalSecondaryIndexOverride,ProvisionedThroughputOverride,OnDemandThroughputOverride,BillingModeOverrideandSSESpecificationOverrideof5before a target of another JSON type. The exception type is SE on DynamoDB and on both trees. #1012 covers DynamoDB's texts, and so the member that each text names.Testing done
94e2ad729dchanges only the module doc, so no wire file ran again. At94e2ad729d, with--locked:cargo +1.97.0 fmt --all -- --checkis clean, and so arecargo +1.97.0 clippy -p extenddb-server --all-targets -- -D warningsand the same command with--features extenddb-engine/backup-test-hooks.cargo +1.97.0 test -p extenddb-server --libgave 522 passed and 5 failed, the same 5backup_store::testsas below.At
e4d210f6a4, 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 522 passed and 5 failed, storage 294 passed. On this host 5backup_store::testsfail on every branch, because uid 65534 owns/local/home.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 279 cases of the corpus. The clippy step of the WebAssembly workflow, run on this branch, is clean.a_restore_target_name_of_another_json_type_is_refused_before_the_backup_arn_value_checkssends5,true,{}and[]with aBackupArnthat the gate refuses, and a null target, which passes. It checks the text by equality. With the text naming another member, it fails.tests/test_backup_restore_fidelity.pypassed 37 tests. Its table of restore names gets the 8 measured values and the four rows with another fault. Against a server built from9444edca4, the fix(engine): check a restore's TargetTableName with the restore's rules #1247 commit that this branch started from, each of these 12 rows gets an answer other than SerializationException.pytest --collect-only -qcollects 7301 tests intests/and 820 intests/python, with no error.Line counts: production +21 -3, tests +43 -2, docs +3 -1.
This PR adds a conflict with #1127 and #1130 in one sentence of the doc of
check_table_name_chars. Both PRs add an exception to "A missing, non-string or empty name passes", and so does this PR. On a rebase, keep both exceptions.#1284 contains
e4d210f6a4and merges with this head with no conflict. #1291 and #1327 containe4d210f6a4too, and so do #1353, #1358, #1359, #1365, #1367 and #1373, which sit on #1327. #1291 rewrites the bullet of the module doc that94e2ad729dchanges, so each of these eight PRs conflicts with this head in that bullet. When one of them merges this head, it keeps its own bullet. Its sentence that starts "The text is the one" then takes the text of this head.Not in this PR, each in an open issue:
BackupArnof another JSON type, a DescribeContinuousBackupsTableNameof another JSON type, and the point-in-time recovery requests (A BackupArn or a DescribeContinuousBackups TableName that is not a JSON string answers ValidationException, where DynamoDB answers SerializationException #1263).Message(SerializationException carries its text undermessage, where DynamoDB sendsMessage#1143).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
A RestoreTableFromBackup
TargetTableNamethat is neither a JSON string nor null gets SerializationException before the checks of the value ofBackupArnand of the overrides. Before this change, such a request got a ValidationException or an AccessDeniedException, as the table in Why shows. A string or null target 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.