Repository navigation
fix(engine): check a restore's override values in DynamoDB's order - #1353
LeeroyHannigan wants to merge 6 commits into
Conversation
RestoreTableFromBackup checked BillingModeOverride against its enum and each ProvisionedThroughputOverride member against 1 before it checked the BackupArn and the TargetTableName. A throughput member below 1 got the text of CreateTable. When the server refused the TargetTableName before authorization, the answer named only the constraints of the name. In that case only, the server answered an override member of another JSON type first. With any other name, it answered a BackupArn of another account first, with AccessDeniedException. The server answered a member of another JSON type inside an override only after the pattern of the name and the cross-account refusal. It checked the members of SSESpecificationOverride only after it read the backup. It read a ProvisionedThroughputOverride list of two numbers as a throughput, and it refused every VectorIndexOverride with a ValidationException of its own. DynamoDB answers an override member of another JSON type first, at any depth of the override, for every BackupArn and every TargetTableName. A list in place of a structure is of another type. An object as VectorIndexOverride is of another type too, because the model has a list there. A missing member and a number with a fraction are not of another type. Then DynamoDB answers a BackupArn of another account, then an absent or malformed BackupArn, then an absent TargetTableName, then the length of the name. Then it lists the constraints of the model in one message. The message names each throughput member below 1, then the BillingModeOverride enum, then the pattern of the name. The id and the region of the BackupArn come after that message. Measured in us-east-1 on 21 Nov 2026. The server now refuses an override member of another JSON type at any depth in every restore, before the cross-account refusal. The engine checks these kinds first, against the members that the model gives each override. It checks the name and the override values after the account and the shape of the BackupArn, and it lists their constraints in one message. The throughput clause is the text of the model, with writeCapacityUnits first. The parse of the overrides and the PROVISIONED rule now come after the id and the region of the BackupArn. Fixes #1271. Fixes #1278.
The new head of fix/1272-invalid-backup-arn holds main. On main, #1009 moved ListBackups and the point-in-time recovery requests from backup.rs to backup_requests.rs, and backup/pitr.rs to backup_requests/pitr.rs. Conflicts: - backup.rs: the use list of extenddb_core::types. This branch removed CreateTableInput, and main removed BackupSummary. The merge removes both. - backup.rs: the body of check_restore_override_kinds. fix/1245-restore-name-after-account copies only the override members of another kind into a new map. This branch compares each member with RESTORE_OVERRIDE_KINDS at any depth. The merge keeps that comparison and copies only the members that it refuses. - backup.rs: the doc of the restore steps, which fix/1136-restore-override-index-name rewrapped. The merge keeps the words of this branch with new line breaks. - backup.rs: the pub use pitr lines at the end of the file, which main removed. The merge removes them. - lib.rs: the pub use backup::{...} list. The merge keeps main's list and adds check_restore_name_and_overrides to it. - backup_requests/pitr.rs: the doc of check_restore_table_name. fix/1224-restore-target-name added an Errors section, and this branch added the earlier clauses. The merge keeps both. - table_name_gate.rs: the doc of the restore target test, where fix/1245-restore-name-after-account added 25 Nov to the dates. The merge keeps the words of this branch with the three dates. This branch removed the export of check_restore_table_name, because the server gate no longer calls it. The merge removes it from the pub use backup_requests line of lib.rs and from backup_requests.rs too.
The doc of validate_override_shape and the comment of step 3 of the restore named #1097 after DynamoDB's order of the PROVISIONED rule. An issue number in a code comment goes out of date when the issue closes. Both sentences state the order without it.
The README lists the checks that the server makes and the WebAssembly build does not. It said that the server checks the JSON kind of each override member of a restore only for a TargetTableName that it refuses. That check came after the kind of the BackupArn. The server now makes it for every restore, at any depth of the override, before the kind of the BackupArn. The member types row now lists it with its two texts. The TargetTableName row lists the clauses of the throughput members below 1 and of the BillingModeOverride enum. They come before the clauses of the name, in one message.
navareamol
left a comment
There was a problem hiding this comment.
This branch is not on the current head of #1327. It sits on 8da64f4, and #1327 is now 2fda6a9, which moved backup/pitr.rs to backup_requests/pitr.rs. A merge of the two conflicts in crates/engine/src/backup.rs, crates/engine/src/backup_requests/pitr.rs, crates/engine/src/lib.rs and crates/server/src/table_name_gate.rs, and a merge with main conflicts in backup.rs and lib.rs. So the description's "git merge-tree shows no conflict with main" no longer holds, and the conflict lists for #1096, #1273, #1110, #1114 and #1126 are out of date. I resolved the conflicts by hand in a scratch tree to check the code. It builds, clippy with warnings as errors is clean, the core, engine, server and storage lib tests pass, and a 3189 request run against a SQLite server answers the same as this head. Could you rebase onto #1327 at 2fda6a9?
CI ran on 21 Nov on the old stack, before main added the wasm job and other checks. I think it needs a run on the rebased branch.
Two tests do not pin what the description says. If a list or an object of the wrong shape inside an override member is no longer compared (for example a KeySchema object or a Projection list in a GSI override), every engine and server unit test still passes. This head refuses both with SerializationException, so the code is right, but nothing fails if it changes. The same holds for validate_name_member_after ignoring earlier: all 226 core tests pass, only an engine test fails. A row for each would pin them. There is also no wire test for the new order, so no CI job runs it through the server. Could you add rows to tests/test_backup_restore_fidelity.py?
One question on numbers. A ReadCapacityUnits of 1.0, 0.0 or 1e0 with a valid target name gets "Start of structure or map found where not expected: invalid type: floating point 1.0, expected i64", and with the name a b it gets the name clause. The below one clause reads the raw number with as_i64(), so 0.0 gets no clause. The parse behaves the same on 8da64f4. Has DynamoDB been sent a whole number written with a fraction?
I will approve once the branch is rebased onto #1327 and CI is green on it, and the two unit pins and a wire row are added.
The new head of fix/1272-invalid-backup-arn holds main of 2 Dec. On main, #1521 moved the WebAssembly section of README.md to docs/webassembly.md. Conflict: - README.md: the WebAssembly section. This branch changed two rows of its table of the checks that the server makes and this build does not. The merge takes the README of fix/1272-invalid-backup-arn. It makes the same two changes in docs/webassembly.md: the new member types row for the restore overrides, and the clauses of the TargetTableName row.
Three checks of the restore had no test that fails when they change. The engine table of the restore's order gets two rows: a KeySchema object and a Projection list inside a GSI override entry. Each one gets a SerializationException before a BackupArn of x or a TargetTableName of "a b". A core test of validate_name_member_after sends a BillingModeOverride clause as earlier. The clause comes before the clause of the name, and alone when the name passes. The wire table of test_backup_and_table_names_are_validated gets seven restore rows for the order. They send the two nested kinds and the shape of the BackupArn. They send the one message of the values and the name, and the two capacity clauses with WriteCapacityUnits first. The last two send the backup id before the PROVISIONED rule. DynamoDB gave these answers on 3 Dec 2026, each request sent twice.
|
Changes since the last review
The branch is at
9a7483aa04. These commits sit on75d06b0b5, the head that the review of 2 Dec 2026 read:31e3bd6edmerges fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327 at2fda6a911. Onmain, feat(wasm): [Add WebAssembly browser support for ExtendDB #1009 moved ListBackups and the point-in-time recovery requests fromcrates/engine/src/backup.rstocrates/engine/src/backup_requests.rs, withbackup/pitr.rsasbackup_requests/pitr.rs. The conflicts:extenddb_core::typesuse list ofbackup.rs: this PR removedCreateTableInput, andmainremovedBackupSummary. The merge removes both.check_restore_override_kinds: fix(server): answer a restore's override kinds and account before its name #1284 copies only the override members of another kind into a new map. The merge keeps the comparison of this PR withRESTORE_OVERRIDE_KINDSat any depth, and copies only the members that it refuses.pub use pitrlines at the end ofbackup.rs, whichmainremoved. The merge removes them.pub use backup::{...}list ofcrates/engine/src/lib.rs:main's list withcheck_restore_name_and_overridesadded.check_restore_table_name: fix(engine): check a restore's TargetTableName with the restore's rules #1247 added an# Errorssection, and the merge keeps it beside the sentence of this PR on the earlier clauses.crates/server/src/table_name_gate.rs: the words of this PR with the dates of fix(server): answer a restore's override kinds and account before its name #1284 (20, 21 and 25 Nov 2026).check_restore_table_name, because the gate no longer calls it. The merge removes it from thepub use backup_requestsline oflib.rsand frombackup_requests.rs.23e8867a4drops the issue number from the doc ofvalidate_override_shapeand from the comment of step 3 of the restore.cfab9313cchanges the table of the checks that the server makes and the WebAssembly build does not. The "member types" row now lists an override member of another JSON kind. The server checks it for every restore, at any depth, before the kind of theBackupArn. TheTargetTableNamerow lists the throughput and billing mode clauses, which come before the clauses of the name in one message.38d1f47f2dmerges fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327's pushed heade3672395cb, which holdsmainof 2 Dec. Onmain, docs(readme): lead with a first request, move WebAssembly to its own page #1521 moved the WebAssembly section ofREADME.mdtodocs/webassembly.md. That section was the only conflict: the merge takes theREADME.mdof fix(engine): answer a missing or malformed BackupArn as DynamoDB does #1327 and makes the two row changes ofcfab9313cindocs/webassembly.md.9a7483aa04adds the tests that the review asked for. The engine table of the restore order gets aKeySchemaobject and aProjectionlist inside a GSI override entry. A core test sends aBillingModeOverrideclause asearliertovalidate_name_member_after. The wire table oftest_backup_and_table_names_are_validatedgets seven restore rows for the order. DynamoDB gave each answer on 3 Dec 2026.What
RestoreTableFromBackup now checks its members in DynamoDB's order:
SerializationException. This holds for everyBackupArnand everyTargetTableName. A list in place of a structure is of another type, and so is an object asVectorIndexOverride. A null, a missing member and a number with a fraction are not of another type.BackupArnof another account getsAccessDeniedException.BackupArngetsInvalid Backup ARN.TargetTableName, and then the length of the name.ProvisionedThroughputOverridemember below 1 (writeCapacityUnitsfirst), then theBillingModeOverrideenum, then the pattern of the name.BackupArn.Before this change, the enum check and the throughput check ran before the checks of the
BackupArnand the name. A throughput member below 1 got the text of CreateTable. A member of another JSON type came first only when the server refused the name before authorization. A member of another type inside an override came after the pattern of the name and the cross-account refusal. The engine checked the members ofSSESpecificationOverrideafter the backup read. The parse read aProvisionedThroughputOverridelist of two numbers as a throughput.The changes:
check_restore_override_kindsincrates/engine/src/backup.rscompares each override member, at every depth, withRESTORE_OVERRIDE_KINDS. That value gives the JSON kind of each member of the public botocore 1.43.81RestoreTableFromBackupInputmodel. The server's name gate (crates/server/src/table_name_gate.rs) and the engine call it first.check_restore_name_and_overridesputs the throughput clauses, the enum clause and the clauses of the name into one message. It runs after the account and the shape of theBackupArn.validate_name_member_afterincrates/core/src/validation/mod.rstakes the clauses that come before the clauses of the name.enum_constraintincrates/engine/src/lib.rsis the helper of fix(engine): refuse ProjectionType and StreamViewType outside their sets #1110, word for word and at the same place. A merge with fix(engine): refuse ProjectionType and StreamViewType outside their sets #1110, fix(engine): refuse the TableClass and SSESpecification DynamoDB refuses #1114 or fix(engine): read SSESpecification in UpdateTable #1126 keeps one copy.docs/webassembly.mdof the checks that the WebAssembly build does not make describes the server's order.Where the overrides' parse refuses a member of another type, the answer keeps the parse's text (#1012). Where the parse accepts the member or refuses it with another exception, the answer is
Start of structure or map found where not expected: <member>. That adds one more literal of a text thatcrates/already writes in 22 places at the head of #1327. The overrides' parse writes it in private functions, and no shared constant exists.The base of this PR is #1327.
Why
These are DynamoDB's answers to 425 RestoreTableFromBackup requests, measured in us-east-1 on 21 November 2026 with signed requests. Each request went out twice and got the same answer both times. No backup exists. The rows combine four
BackupArnforms (the caller's account,x, the backup idbad, another account) with three target names (valid,ab,a b) and the override faults. The column of this PR is a SQLite server built from75d06b0b5.No request that #1327 answers as DynamoDB does gets another answer here.
The 9 requests with another exception type:
SSETypeoutside its enum inside an override (RestoreTableFromBackup: a missing member, an enum value or a fraction inside an override does not get DynamoDB's validation clause #1348).Of the 205 requests with the same type and another text, 174 get ExtendDB's texts for a member of another JSON type (#1012). Of the others, 30 are #1348 rows and 1 is the region row of #1326.
On 3 December 2026 DynamoDB gave the answers of the new tests, each request sent twice. A
KeySchemaobject or aProjectionlist inside a GSI override entry getsSerializationExceptionbefore aBackupArnofxand before aTargetTableNameofa b.Refs #1271
Fixes #1278
Testing done
At
9a7483aa04, 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 982 passed, server 523 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.py37 passed andtests/test_authz_cross_account.py19 passed.pytest --collect-only -qcollectstests/andtests/pythonwith no error.9a7483aa04: with the kind check limited to values that are not lists or objects,a_restore_checks_its_members_in_the_services_orderfails. Withearlierignored invalidate_name_member_after, the new core test fails.75d06b0b5, a control restored the kinds check of the previous revision. Then the 8 new rows of the engine table and the 8 new rows of the gate table failed, and no other row failed.75d06b0b5, the 425 requests went twice to a SQLite server built from that commit. Each request got the same answer both times.Line counts at
9a7483aa04, against #1327's heade3672395cb: production +217 -86, tests +319 -27, docs +2 -1. 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. 106 open PRs change the files of this PR and of the PRs above it. Three of them get a new conflict from this PR:crates/engine/src/backup.rsand one hunk ofcrates/engine/src/backup/tests.rs. Both PRs check the throughput members against 1. If this PR merges first, fix(engine): give RestoreTableFromBackup override conflicts DynamoDB's texts #1096 drops itsbelow_oneblock and keeps its other changes. If fix(engine): give RestoreTableFromBackup override conflicts DynamoDB's texts #1096 merges first, this PR drops fix(engine): give RestoreTableFromBackup override conflicts DynamoDB's texts #1096'sbelow_oneblock. It keeps fix(engine): give RestoreTableFromBackup override conflicts DynamoDB's texts #1096's PROVISIONED text invalidate_override_shapeand the deletion ofinvalid_provisioned_throughput_override_matches_create_table. One copy of the check remains.crates/core/src/validation/mod.rs. If fix(engine): answer the IndexName faults of both restore override lists #1273 merges first, this PR adds a first argumentearlier: &[(&str, &str, &str)]to fix(engine): answer the IndexName faults of both restore override lists #1273'svalidate_name_membersand dropsvalidate_name_member_after. If this PR merges first, fix(engine): answer the IndexName faults of both restore override lists #1273 adds itsmembersloop tovalidate_name_member_afterin the same way. One function remains.provisioned_below_minimum_error. It calls that function invalidate_override_shapeofcrates/engine/src/backup.rs, and it editsinvalid_provisioned_throughput_override_matches_create_table, which this PR removes. So the two PRs conflict in one hunk of each ofbackup.rsandbackup/tests.rs. Whichever merges second builds the restore's clauses from one helper, so the text is written once. This PR came first (21 November 2026, fix(core): name the capacity member and value when it is below 1 #1442 on 24 November).#1110, #1114 and #1126 merge with this head without a conflict.
Not in this PR:
IndexNameclauses of the index overrides (RestoreTableFromBackup checks an override value before the BackupArn and the TargetTableName length, where DynamoDB checks those first #1271). DynamoDB lists them in the same message as the override values and the name (measured on 25 November 2026). For a restore with"BillingModeOverride": "PAY"and aLocalSecondaryIndexOverrideentry with theIndexNameg i, DynamoDB answers2 validation errors detected: Value 'PAY' at 'billingModeOverride' failed to satisfy constraint: Member must satisfy enum value set: [PROVISIONED, PAY_PER_REQUEST]; Value 'g i' at 'localSecondaryIndexOverride.1.member.indexName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+. This PR answers1 validation error detected: Value 'PAY' at 'billingModeOverride' failed to satisfy constraint: Member must satisfy enum value set: [PROVISIONED, PAY_PER_REQUEST].VectorIndexOverridelist with its own text after the check of the backup id. DynamoDB checks the members of the list entries there. For example, anIndexNameof 2 characters gets a length clause before the check of the backup id (measured on 21 November 2026). The empty list is in RestoreTableFromBackup: a missing member, an enum value or a fraction inside an override does not get DynamoDB's validation clause #1348.ReadCapacityUnitsof1.0or1e0as 1, and gives0.0the clauseValue '0' at 'provisionedThroughputOverride.readCapacityUnits'(measured on 3 December 2026). Here the parse refuses all three withSerializationException, as onmain. fix(core): truncate and clamp a capacity figure, then bound it #1167 changes the parse. The below-1 clause of this PR reads the figure withas_i64(), which gives no value for0.0.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 answers some requests with another exception or text than before, as What and the table in Why give. An override member of another JSON type, at any depth, gets
SerializationExceptionbefore every other check. The restore refuses aProvisionedThroughputOverridelist of two numbers, which it read as a throughput before. AProvisionedThroughputOverridemember below 1 gets the clause of the model atprovisionedThroughputOverride.writeCapacityUnitsorprovisionedThroughputOverride.readCapacityUnits, where it got the text of CreateTable. The restore answers a request with more than one fault in the order that What lists. A client that matches on the old answers sees the new ones. A restore with valid overrides 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.