Repository navigation
fix(engine): check the IndexName of a restore's index override - #1225
LeeroyHannigan wants to merge 10 commits into
Conversation
ExtendDB counted an index name in UTF-8 bytes and wrote both length bounds in one clause. It reported each fault at the bare 'indexName', except a pattern fault in an UpdateTable Create or Delete. DynamoDB counts the name in characters. It writes one clause per failed constraint at the member path, and two clauses share one message. So a name of 128 U+1F600 was refused as too long, where DynamoDB reports the pattern alone. A name of two U+1F600 got the pattern clause alone, where DynamoDB also reports the length. validate_index_name now takes the member path and calls validate_name_member, which moves from the engine's backup module to core. Each caller passes the path of its member. CreateTable passes it for each GSI, LSI and vector index. UpdateTable passes it for each GlobalSecondaryIndexUpdates action and each VectorIndexUpdates action. DynamoDB lists the two clauses in either order. ExtendDB writes the length clause first, as it does for table names. Measured in us-east-1 on 2026-11-06, 2026-11-14 and 2026-11-18. Fixes #1021. Fixes #904.
RestoreTableFromBackup did not check the IndexName of a GlobalSecondaryIndexOverride or LocalSecondaryIndexOverride entry. It looked the name up in the backup and refused a name the backup did not hold with its own text. DynamoDB checks the name against the model's constraints, 3 to 255 characters of [a-zA-Z0-9_.-], at the entry's member path. It reports each failed constraint, as for a CreateTable index. DynamoDB checks the names after the account of BackupArn and after TargetTableName, and before it reads the backup. A bad name with another account's BackupArn gets AccessDeniedException. A bad name with a TargetTableName of two characters gets the fault of the target name. A bad name with a backup that does not exist gets the fault of the name. The restore now checks each entry's IndexName with validate_index_name after TargetTableName and before the backup is read. The fault is at globalSecondaryIndexOverride.<n>.member.indexName or localSecondaryIndexOverride.<n>.member.indexName, numbered from 1. Measured in us-east-1 on 18 and 20 Nov 2026. Fixes #1136.
#1009 moved `validate_name_member`, `table_name_bounds` and the other request checks of `crates/engine/src/backup.rs` to `crates/engine/src/backup_requests.rs`. This branch moved `validate_name_member` to `extenddb_core::validation`, so the merge deletes the copy in `backup_requests.rs` and imports the one in core in both files. The `table_name_bounds` doc change moves with the function.
an_index_name_is_refused_at_its_member_path built its expected text with validation_errors, the function that validate_name_member calls to write the message. A fault in validation_errors would change both sides of the assertion, and the test would pass. The test now writes the sentence itself, as the core test does.
The index override check in step (3) left a short line in the middle of the paragraph. The words do not change.
navareamol
left a comment
There was a problem hiding this comment.
I think the test does not check that the catalog index is left unread. source_reads in Fake counts only restore_source, the legacy reader. When I moved index_overrides.check_index_names()?; to just after read_catalog_row, an_index_override_name_is_checked_before_the_backup_is_read still passed. Removing the call, or placing it before the BackupArn check or before the target name check, fails it as the description says. Could you count read_backup_row calls in Fake and assert zero there too?
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 current main into this head locally: no conflict, the engine and core lib tests pass, and tests/test_backup_restore_fidelity.py plus tests/python/test_warm_throughput_backup.py pass on SQLite (38). Could you merge main so CI runs on that tree?
A question on the order: the name check runs after the override parse, so a bad BillingModeOverride or a missing BackupArn wins over a bad override name. With BillingModeOverride BOGUS and an override name g i, ExtendDB answers only the billingModeOverride enum fault, and with no BackupArn only the backupArn null fault. #1227 shows DynamoDB lists the name faults of both lists in one answer. Has anyone sent these two requests to DynamoDB, to see whether it lists the name fault beside the other one?
I will approve once the test counts the catalog read and CI is green on a branch with main merged.
…override names The test counted only the reads of the legacy reader, restore_source. With the name check moved after read_catalog_row, it still passed. It now also checks that the fake records no read_backup_row call.
|
…ssage CodeQL reads the account of a test BackupArn in an assertion message as cleartext logging of sensitive information (alert 259). The message of the assertion in an_index_override_name_is_checked_before_the_backup_is_read now names the field, the index name and the target. The compared values still show the row that fails.
navareamol
left a comment
There was a problem hiding this comment.
No open points on this PR at 6194166.
The catalog read is covered. With index_overrides.check_index_names()?; moved to just before let mut legacy = None;, an_index_override_name_is_checked_before_the_backup_is_read now fails at the new row_reads assertion, where before it passed. Removing the call, or putting it before the BackupArn check or before the target name check, still fails it. You are right that the fake already recorded read_backup_row; the gap was only that the test did not assert on it.
CI is green on this head after the merge of main, 70 of 70 checks including wasm. Main as it is now merges into this head with no conflict. On SQLite the head passes the engine lib tests (981), tests/test_backup_restore_fidelity.py and tests/python/test_warm_throughput_backup.py, and a bad override name keeps its texts and member paths for the first and the second entry, with an existing backup and with a missing one.
On the order, your measurements settle my question. An absent BackupArn is answered before the override names, as this PR does. For BillingModeOverride BOGUS with g i, DynamoDB lists the enum fault and the name fault in one answer, and ExtendDB answers the enum fault alone. I see the same, because the restore parses the override values at step 1, before the names. That is #1271, not this change.
I approve this PR.
Changes since the last review
a31f385eebmergesmainatb3510a93ee, which contains fix(core): count an index name in characters and report its member path #1137 and fix(core): read the latency segment clock through web_time #1482. The merge has no conflict, and the lines this PR changes stay the same. fix(core): count an index name in characters and report its member path #1137 merged on 2 December, so the base of this PR is nowmain.26dcbe1d73:an_index_override_name_is_checked_before_the_backup_is_readalso checks that the restore reads no catalog row. The fake records eachread_backup_rowcall, and the test asserts that there is none. Before, the test counted only the reads of the legacy reader, so a name check afterread_catalog_rowpassed it.What
RestoreTableFromBackup did not check the
IndexNameof aGlobalSecondaryIndexOverrideorLocalSecondaryIndexOverrideentry. ExtendDB searched the backup for the name, so a backup that does not exist answeredBackupNotFoundException. DynamoDB checks the name against the model's constraints, 3 to 255 characters of[a-zA-Z0-9_.-]. It answers the fault at the entry's member path before it reads the backup.IndexOverrides::check_index_namesincrates/engine/src/backup/overrides.rschecks each entry's name withvalidate_index_name, which takes a member path since #1137, atglobalSecondaryIndexOverride.<n>.member.indexNameorlocalSecondaryIndexOverride.<n>.member.indexName.restore_table_from_backupincrates/engine/src/backup.rscalls it after theBackupArncheck and theTargetTableNamecheck, and before it reads the catalog row or the backup. DynamoDB answers another account'sBackupArnand a badTargetTableNamefirst, so the check does not run in the override parse, which comes before both.Why
DynamoDB's answers, measured in us-east-1 on 18 and 20 November 2026. Each request went out twice and got the same answer both times. Each request named a backup that does not exist, and each override entry carried a
KeySchemaand aKEYS_ONLYprojection.GlobalSecondaryIndexOverrideentryIndexNameValidationExceptionab1 validation error detected: Value 'ab' at 'globalSecondaryIndexOverride.1.member.indexName' failed to satisfy constraint: Member must have length greater than or equal to 3😀😀(two U+1F600)2 validation errors detected:, the length clause andMember must satisfy regular expression pattern: [a-zA-Z0-9_.-]+g i1 validation error detected:, the pattern clause1 validation error detected:,Member must have length less than or equal to 255A
LocalSecondaryIndexOverrideentry gets the same texts atlocalSecondaryIndexOverride.1.member.indexName. Before this change, ExtendDB answered each row withBackupNotFoundException. With this change, it answers each row as DynamoDB does.More requests with the override name
g iset the order of the checks. DynamoDB gave the last two answers on 3 December 2026, each request sent twice.BackupArnof another accountAccessDeniedException,Access is deniedTargetTableNameabBackupArnInvalid Backup ARN, without the override nameBillingModeOverrideBOGUS2 validation errors detected:, the enum clause atbillingModeOverride, then the pattern clause atglobalSecondaryIndexOverride.1.member.indexNameExtendDB answers the first three in DynamoDB's order. Their texts differ from DynamoDB's (#1116, #1224, and #1272 for the absent
BackupArn). For the last row, ExtendDB answers the enum clause alone, because the engine checks the override values before the names (#1271).Fixes #1136
Testing done
At
26dcbe1d73, 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 981 passed, server 521 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.an_index_override_name_is_checked_before_the_backup_is_readsends 12 requests, 6 per list: the four names above, another account'sBackupArn, andTargetTableNameab. The store holds no backup. The test reads each answer and checks that the restore reads neither the catalog row nor the backup. It fails with the call removed, and with the call placed before theBackupArncheck or before the target name check. At26dcbe1d73, with the call moved after the firstread_catalog_row, the test fails at its first row, because the restore reads the catalog row.tests/test_backup_restore_fidelity.pypassed 37 tests andtests/python/test_warm_throughput_backup.pypassed 1. In the first file,test_backup_and_table_names_are_validatedholds the six rows of the issue. Against a server built from fix(core): count an index name in characters and report its member path #1137's head8a2b168a1, it fails withBackupNotFoundExceptionwhere it expectsValidationException.pytest --collect-only -qcollects 7301 tests intests/and 820 intests/python, with no error.Line counts: production +24 -4, tests +90 -2.
Not in this PR:
.2., as ExtendDB does. For a bad name in each list, DynamoDB lists both faults, the LSI entry first, where ExtendDB reports the GSI entry alone (RestoreTableFromBackup with a bad IndexName in both override lists answers one fault, where DynamoDB lists both, the LSI entry first #1227).TargetTableNametext forabdiffers from DynamoDB's (RestoreTableFromBackup answers a TargetTableName of 2 characters with CreateTable's text, where DynamoDB answers "TableName must be at least 3 characters long and at most 255 characters long" #1224).AccessDeniedExceptionbody for another account'sBackupArnhas another__typenamespace and message key than DynamoDB's (UpdateTable with a table ARN of an account that does not exist answers AccessDeniedException with another __type and message key than DynamoDB #1116).This PR adds no conflict with an open PR or with
main.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 whose index override has an
IndexNamethat DynamoDB refuses gets DynamoDB'sValidationExceptionbefore ExtendDB reads the backup. Before this change, such a request for a backup that does not exist gotBackupNotFoundException. A request with valid override names 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.