Repository navigation
fix(engine): validate numbers on every key and item path - #620
Conversation
validate_and_normalize_number parsed the exponent as an i32. #394 moved its exponent sums to saturating i64 arithmetic, which fixed the overflow panics of #616, but an exponent outside the i32 range was still refused as malformed. The exponent is now parsed as an i64 and the sums are done in i128 instead of saturating i64, so none of them can overflow. DynamoDB reads the exponent the same way: 1E2147483648 is a Number overflow and 1E9223372036854775808 cannot be converted. A zero whose exponent does not fit in an i32 is range checked too; main refused those as malformed. A zero whose exponent fits in an i32 stays accepted as 0, although DynamoDB refuses 0E126 and 0.0E-130. A refused zero keeps its raw spelling in AttributeValue, and only the PutItem item and UpdateItem's update values are validated afterwards, so UpdateItem's key and the other operations would store 0E126 as a key separate from 0. #618 covers both. Closes #616
95997b6 to
bfde5fd
Compare
Only the PutItem item and UpdateItem's update values were checked. AttributeValue keeps a number it cannot read as written, so GetItem, DeleteItem and UpdateItem keys, BatchGetItem and TransactGetItems keys, BatchWriteItem writes, every TransactWriteItems action, and PutItem and DeleteItem condition values used values such as abc and 1E126 as written, where DynamoDB refuses them with a ValidationException. Each of those paths now checks its N and NS values with the text that operation answers. PutItem, UpdateItem and DeleteItem start the message with "1 validation error detected: ", the other operations do not, and a TransactWriteItems value names its placeholder. BatchWriteItem, TransactGetItems and TransactWriteItems read a number with a 32-bit exponent and scale, as DynamoDB does on those operations, so 10E2147483647 is a Number underflow there and a Number overflow on the others. Each check is placed where DynamoDB reports it, unless that position would change the answer to a request with a second fault that main already answers as DynamoDB does. The ClientRequestToken check now runs before the actions, as on DynamoDB. A zero whose exponent fits in an i32, such as 0E126, stays accepted as 0 until Query, Scan and ImportTable validate numbers. A zero whose exponent does not fit is range checked on its magnitude, which makes 0E9223372036854775807 a Number underflow, as on DynamoDB. Part of #618
number_validation_all_ops covers each validated path with DynamoDB's message for abc, 1E126 and the 32-bit edge values, a refused batch or transaction writing nothing, and valid zeros stored as 0. number_validation_order pins the position of each check against a second fault in the same request: an absent table, a mixed-parameter error, an unused name, a projection or condition syntax error in another item, a duplicate key and a long ClientRequestToken. Each expectation is a DynamoDB answer measured twice on 2026-10-27. Part of #618
909482b to
41bc6e4
Compare
… comparison SET a = b + c, SET a = b - c and a number ADD parsed both operands with bigdecimal and range checked only the result. bigdecimal aligns operands to the larger scale before adding them, so the cost of a sum grows with the gap between their exponents, and an operand read from an item stored without the number checks (#618) could build an integer of about 10^9 digits. Each operand is now range checked and parsed from its normalized text. A stored operand that is not a number answers the service's text without the stored value. The result is stored as the service spells it (2.25 - 0.25 is 2, not 2.00), and a result out of range keeps the Number overflow answer, as measured on DynamoDB on 2026-11-03. Numbers in condition and filter comparisons are parsed the same way, which bounds bigdecimal's quadratic parse for values that are not checked before the expression maps are built. A placeholder the check refuses is recorded once per request, and a number the service cannot store compares as a value of another type, so only <> is true for it.
… does ImportTable stored a row's numbers as written. Each row's numbers are now read as BatchWriteItem reads them, before the other row checks: a value that is not a number ends the import of the file, and a number out of range skips the row. Either counts as one error, and an import with any error answers FAILED with ItemValidationError and keeps the rows it imported, as measured on DynamoDB on 2026-11-03. Each refused row is logged with the import ARN, the table name and its item number, with the error text escaped. A zero with an out-of-range exponent and a Unicode decimal digit are still read differently from the service; both are recorded in docs/differences-from-dynamodb.md.
The MongoDB fast path for a number ADD adds a Decimal128 in an update pipeline and does not read the stored value first. A Decimal128 keeps 34 digits and holds magnitudes DynamoDB refuses. After 5E125 + 5E125, GetItem returned 1.000000000000000000000000000000000E+126, where the update evaluator answers Number overflow. After 38 nines + 1, it returned 99999999999999999999999999999999990000, where the exact sum is 1E38. The fast path now takes a delta whose normalized text is an integer of at most 33 digits, or has at most 20 digits before the decimal point and 13 after it. Its filter admits a stored value written without an exponent, within limits that keep the sum within 34 digits: an integer of up to 33 digits when both operands are integers, and up to 20 and 13 digits when either has a fraction. Any other ADD takes the session path, where the update evaluator range checks both operands and the sum. The delta is the Decimal128 of its normalized text, so 1E3 is added as 1000. On MongoDB 7, fifty threads sending 20 ADD calls each to one item, with SDK retries off, gave no errors and the exact total for deltas of 1, 0.5 and 0.001, for 1 added to a stored 0.5 and to a stored 21-digit integer, and for a 25-digit delta.
fix(expression): range check numbers before bigdecimal arithmetic and comparison
fix(import): check the numbers in each ImportTable row as the service does
|
@LeeroyHannigan Reviewed so far -- status while this waits on #619. The core change is good on the backends I ran. Every path that this change Three things block a merge.
One open decision. After this change, an item that was stored under an invalid I will review again once #619 lands, this change is rebased on current main, the |
pdf-amzn
left a comment
There was a problem hiding this comment.
needs rebase, I suggest you wait until 619 lands then revisit this PR
|
AI generated: This waits on #619 and a rebase, as @eliseong said. I reviewed the core and engine changes only, not the MongoDB commit (5803642), and skipped what she already raised. I haven't run the tests, since the branch doesn't merge. Rebase notes. Against main the conflicts are in resolver.rs, import_export.rs, put_item.rs and transact_write_items.rs; against #619's head, number.rs too.
Should-fix: legacy Expected values are not checked. operations::put_item_values (crates/core/src/validation/number/operations.rs:119) and delete_item_values (:99) cover ExpressionAttributeValues only, so Expected[].Value and Expected[].AttributeValueList on PutItem, DeleteItem and UpdateItem still reach the evaluator as written. Either measure and add the checks, or list them in #618 with the Query/Scan inputs that also stay unchecked (KeyConditions, QueryFilter, ScanFilter, ExclusiveStartKey, ExpressionAttributeValues). Should-fix: order against main's attribute-name-size checks is unmeasured. Every measurement in this PR predates them. After the rebase, PutItem, DeleteItem, UpdateItem, BatchWriteItem and TransactWriteItems each have a new two-fault case (an over-long attribute name plus a malformed number) whose order git picked textually. TransactWriteItems also has the client token against a name-size fault. Measure one two-fault row per operation and add it to tests/rust/src/number_validation_order.rs. Should-fix: there are now two Java-BigDecimal 32-bit readers, and they disagree. Main's crates/core/src/partiql/number.rs:171 check_number and this PR's validate_number_i32_scale (operations.rs:393) parse the same grammar with the same limits, but PartiQL checks the 38-digit count before the magnitude and accepts any zero whose scale fits, while this PR checks the magnitude first and range-checks zeros. Either the service differs between PartiQL and BatchWriteItem, which needs a measured note in both files, or one of them is wrong. After the rebase, implement it once and keep the per-operation message formatting at the call sites. Should-fix: import row errors are classified by message text. import_row (operations.rs:281) and arithmetic_operand (crates/core/src/expression/update_evaluator.rs:201) tell "not a number" from "out of range" with Should-fix: ImportTable now marks any import with row errors FAILED/ItemValidationError (import_export.rs:233), not only number errors. Imports with key-type, nesting, size or name-size errors also change from COMPLETED to FAILED. Only number rows are tested (tests/test_import_export.py:505-680). Add one test with a key-type-mismatch row and no bad numbers, and say so in the PR body. Should-fix: no Python dual-target tests for the data-plane paths. The new Python tests cover ImportTable only, which runs against ExtendDB only. The key, ExpressionAttributeValues, batch and transaction paths, "a refused batch writes nothing", and the comparison/arithmetic change are covered only by the Rust wire tests. Those are dual-target, but add at least one Python test per message form (no prefix, Should-fix: the PR body is stale. It says ImportTable doesn't validate numbers, but 979c750 (#804) does. It says the branch merges cleanly, but it now conflicts in 4 files. It doesn't mention d3a5b1c (#803), which changes comparisons: a stored out-of-range N now makes only <> true (crates/core/src/expression/evaluator.rs:147), where main made every operator false. Nit-or-follow-up: operations.rs:193-204. transact_write_item names the condition expression Nit-or-follow-up: value_numbers (operations.rs:326) duplicates validate_expression_attribute_value_numbers (crates/core/src/validation/mod.rs:1198). Share one. Nit-or-follow-up: put_item_item (operations.rs:140) walks the item for numbers and nesting, then validate_put_item walks it again, up to 400 KB. The same goes for the nesting walk in delete_item_values and put_item_values. Pass a flag or drop the later walk. Nit-or-follow-up: comparison_number (evaluator.rs:147) now validates and normalizes every non-placeholder N in every comparison, so a filtered Scan pays it per item per comparison. Fine as a bound; a benchmark note would help. Nit-or-follow-up: validate_number_i32_scale allocates Nit-or-follow-up: the thread-plus-timeout test harness appears three times (eval_within_10_s in evaluator_tests.rs, inline in a_refused_placeholder_is_read_once_per_request, update_n in update_evaluator_tests.rs). Factor it into one helper. |
…he wire The backup-failure note said DeleteItem deletes an item stored under an invalid number key. On this branch every write that names such a key is refused for the key number. So the item cannot be rewritten or deleted through the wire. #982 tracks a way to delete it.
|
Pushed 0daa2b8..7527dcd. This push merges current main (511d6c7) and fixes the TransactWriteItems crash. @eliseong 8b2504f fixes the crash. The per-action number check now runs before prepare_write_op, the way BatchWriteItem already does it. So the item is never sized while it holds a number the service cannot read. A Put with 1E9223372036854775807 now answers Number overflow. A Put with 1E-9223372036854775808 answers Number underflow. The server stays up. I measured both on the service and on a local SQLite build on 2026-11-12, each value six times. Within an action the service answers a number ahead of the action's other faults. The reorder matches that. The same holds beside a missing table, a syntax error, an unused value, an empty key, a key update or an oversize item. Each went out six times on 2026-11-12. The number_validation_order and number_validation_all_ops suites carry these as new cases. BatchWriteItem keeps the 64-bit reader, as you asked. The docs said DeleteItem deletes an item stored under an invalid number key. On this branch every write that names such a key is refused for the key number. So the item cannot be deleted through the wire. 7527dcd updates both docs. #982 tracks how to delete such an item. @pdf-amzn The re-merge had one conflict, in batch_write_item.rs. The number check stays after the attribute name size checks and before the table lookups, where #475 moved the table reads into write_batch. |
eliseong
left a comment
There was a problem hiding this comment.
LGTM
The TransactWriteItems Put that ended the server is fixed. Each action's numbers
are now checked before the item is sized, the same as BatchWriteItem. I
confirmed on a debug build: a Put with 1E9223372036854775807 or
1E-9223372036854775808 now answers Number overflow or Number underflow and the
server stays up, as a plain attribute, nested in a list and a map, and as the
sort key. A valid Put still writes.
BatchWriteItem reads the exponent in 64 bits, the same as PutItem,
TransactWriteItems and TransactGetItems: a positive out-of-range exponent is
Number overflow and a negative one is Number underflow. That is the correct
answer and it is deterministic in the local tests.
The branch is rebased on current main and merges clean.
The merge of main dropped the _write_batch, _write_transact, _write_update and _write_import helpers and the WRITE_PATHS map from test_backup_job.py. It kept the tests that call them. The backup suite then failed with NameError: name '_write_batch' is not defined, which is why every job that runs the backup suite went red. This takes main's test_backup_job.py whole. Main's backup suite is newer, and its parametrized write-path tests cover the one older branch test they replace. #620 does not change backup behaviour and adds nothing to this file.
A merge took main's test_backup_job.py, which seeds the #618 items through BatchWriteItem, TransactWriteItems, UpdateItem and ImportTable. This branch refuses those writes, so the setup raised ValidationException and the backup tests failed. Seed the items into storage, as this branch did before the merge, and keep the new migrate-legacy tests. Verified on SQLite (5 target tests pass) and on MongoDB (tests/test_backup_job.py: 28 passed, 18 skipped, 0 failed).
jcshepherd
left a comment
There was a problem hiding this comment.
Okay. A few minor comment inconsistencies but not holding it up for that.
This commit merges main at 3a5c84b (#620), four commits past ce3a51a. #620 adds number checks on the key, item and value paths. Five files conflicted with the #399 commits that this branch carries. crates/core/src/expression/mod.rs: both sides added a module. The merge keeps the #399 semantics module and the test_timeout module from main. crates/core/src/expression/evaluator.rs: both sides added a function after placeholder_numeric. The merge keeps compare_orderable from #399 and comparison_number from main. crates/engine/src/put_item.rs and crates/engine/src/delete_item.rs: main added the ExpressionAttributeValues and Expected number checks above the validate_expression_param_usage call. #399 added a comment about that call in the same place. The merge puts the number checks first, then the #399 comment and the call that it describes. crates/engine/src/transact_write_items.rs: main moved the client request token check to the start. On main, the handler also checks the numbers of each action before it prepares that action. #399 checks the items in phases, and phase 1 checks each item without a table lookup. The token check stays at the start. The number check moves into phase 1, after the attribute name sizes and before the item size. ExtendDB still does not size a Put item that holds a number the service cannot read. A number in a later action now comes before a missing table in an earlier action. #620 measured that order on the service. The phase list in the comment names the number check. The duplicate check stays after the key pass, as in #399. Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
validate_legacy_number called validate_attribute_number and matched the text it gives for an empty number, to add the separator. #620, now in main, added attribute_numbers(EmptyText::WithColon, ..) to crates/core/src/validation/number/operations.rs. That function gives the text with the separator for an empty number in N or NS, and inside L and M. validate_legacy_condition now calls condition_values, a new pub function in operations.rs that runs attribute_numbers on each value in the list. This commit removes validate_legacy_number. validate_attribute_number is private again, as it is on main, because the engine no longer calls it. ExtendDB's answers do not change. The engine unit tests and tests/test_legacy_condition_parity.py pass with no change to the tests. That includes the empty number rows in N, NS, L, M and an M in an L. Signed-off-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
Main (#620) added number_value, which reads a number from the text the number check normalizes, at most 170 characters. Parsing the text as written takes time quadratic in its length, and a request body can carry 16 MiB. compare_orderable, which the legacy BETWEEN bound check calls for ScanFilter, QueryFilter and KeyConditions, still parsed both bounds as written. It now reads them with number_value, as comparison_number does. For a number the check accepts, the value and the answer do not change. For a bound that the check refuses, compare_orderable now returns None, as it did for a value that is not a number. The range check then does not refuse the request. A new test in evaluator_tests.rs sits beside the test that #620 added. It checks that a bound of 1 with two million trailing zeros compares equal to 1 within 10 seconds. The phase comments in transact_write_items.rs and transact_get_items.rs now say where the number checks from main run. TransactWriteItems checks the ExpressionAttributeValues of a Put or Delete only with a ConditionExpression. TransactGetItems checks the numbers of each key in its first loop.
Main (#620) added number_value, which reads a number from the text the number check normalizes, at most 170 characters. Parsing the text as written takes time quadratic in its length, and a request body can carry 16 MiB. compare_orderable, which the legacy BETWEEN bound check calls for ScanFilter, QueryFilter and KeyConditions, still parsed both bounds as written. It now reads them with number_value, as comparison_number does. For a number the check accepts, the value and the answer do not change. For a bound that the check refuses, compare_orderable now returns None, as it did for a value that is not a number. The range check then does not refuse the request. A new test in evaluator_tests.rs sits beside the test that #620 added. It checks that a bound of 1 with two million trailing zeros compares equal to 1 within 10 seconds. The phase comments in transact_write_items.rs and transact_get_items.rs now say where the number checks from main run. TransactWriteItems checks the ExpressionAttributeValues of a Put or Delete only with a ConditionExpression. TransactGetItems checks the numbers of each key in its first loop.
…main Main (#620) checks a PutItem Item's numbers and nesting in put_item_item, ahead of the mixed-parameter check. It checks the ExpressionAttributeValues nesting and numbers in put_item_values, after that check. This branch ran the same three checks again after validate_table_name. The second copies could not fail after the first ones. They are gone. The behaviour this branch added, the Item's error ahead of every condition fault, holds through main's checks. The two comments from main said that validate_put_item and a later nesting check repeat these checks. This branch removed both repeats, so the comments now say that the checks run once. They also carry the measurements this branch recorded. The Item's error comes beside a condition fault, with or without ExpressionAttributeValues. TransactWriteItems checks its values in validate_value_map_nesting.
Moves the workspace version from 0.1.15 to 1.0.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 14 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (version and the five platform pins), the four licence-notice files (regenerated with cargo-about 0.9.0), and the example `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. RELEASED_THROUGH stays 12: migration 12 is still the last one, so 1.0.0 carries the catalog of 0.1.15 and freezes nothing new. Upgrade manual: - Behavior Changes by Release gets a v1.0.0 entry for #945: the Cassandra backend reads and writes at LOCAL_QUORUM where 0.1.15 ran many of them at ONE, so a request fails with HTTP 500 while fewer than a quorum of its keyspace's replicas are up. It says what to do before upgrading: a replication factor of 3, as cassandra-setup.md describes. - Current Status, the General Upgrade Procedure and the Rollback Procedure cover 0.1.15 to 1.0.0, with that Cassandra step. Current Status says which of its paragraphs are for 0.1.14 and earlier and that the backup store notes apply to every deployment. - A v0.1.15 entry for the request validation of #619, #620, #830 and #1000, which had none. It says the expression depth limit is ExtendDB's own. - The rollback to 0.1.14 or earlier states what a binary of those releases does on a migrated catalog, as measured on PostgreSQL with 0.1.14 and 0.1.10: exit status 1, "invalid catalog version '12'". docs/versioning.md: the 0.1.x releases get no more fixes. The Docker Hub pages name 0.1.15 as the first keyless-signed release. docker/README-mongodb.md ran extenddb/extenddb-mongodb:0.1.8; it now runs X.Y.Z, as the other image READMEs do. doc_version_literals now reads docker/ as well, so a stale image tag there fails it. It reports each image tag once, and skips another project's image tag and a link to a release. The npm launcher test now checks that the launcher refuses the release line before an X.0.0 launcher, which it skipped at patch 0. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
Moves the workspace version from 0.1.15 to 1.0.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 14 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (version and the five platform pins), the four licence-notice files (regenerated with cargo-about 0.9.0), and the example `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. RELEASED_THROUGH stays 12: migration 12 is still the last one, so 1.0.0 carries the catalog of 0.1.15 and freezes nothing new. Upgrade manual: - Behavior Changes by Release gets a v1.0.0 entry for #945: the Cassandra backend reads and writes at LOCAL_QUORUM where 0.1.15 ran many of them at ONE, so a request fails with HTTP 500 while fewer than a quorum of its keyspace's replicas are up. It says what to do before upgrading: a replication factor of 3, as cassandra-setup.md describes. - A v1.0.0 entry for #1003. Without key_file the stored format and the catalog key stay as they are, and 0.1.15 and 1.0.0 each read the access keys the other wrote. serve and the backup commands refuse a catalog key that is not 32 bytes in base64, where 0.1.15 started and failed every signed request with HTTP 500; the entry says how to check the key before upgrading. The key moves into a locked key store, with a warning when the memlock limit is too low. key_file and the encryption-key commands are opt-in and link to the admin guide. - The rollback section of #1003 now gives the PostgreSQL refusal of 0.1.15 on a switched catalog: the encrypted connection string row stops it with exit status 1 before the missing key does. - Current Status, the General Upgrade Procedure and the Rollback Procedure cover 0.1.15 to 1.0.0, with the Cassandra step, the key check, and the rollback after encryption-key switch. Current Status says which of its paragraphs are for 0.1.14 and earlier and that the backup store notes apply to every deployment. - A v0.1.15 entry for the request validation of #619, #620, #830 and #1000, which had none. It says the expression depth limit is ExtendDB's own. - The rollback to 0.1.14 or earlier states what a binary of those releases does on a migrated catalog, as measured on PostgreSQL with 0.1.14 and 0.1.10: exit status 1, "invalid catalog version '12'". docs/versioning.md: the 0.1.x releases get no more fixes. The Docker Hub pages name 0.1.15 as the first keyless-signed release. docker/README-mongodb.md ran extenddb/extenddb-mongodb:0.1.8; it now runs X.Y.Z, as the other image READMEs do. doc_version_literals now reads docker/ as well, so a stale image tag there fails it. It reports each image tag once, and skips another project's image tag and a link to a release. The npm launcher test now checks that the launcher refuses the release line before an X.0.0 launcher, which it skipped at patch 0. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
Moves the workspace version from 0.1.15 to 1.0.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 14 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (version and the five platform pins), the four licence-notice files (regenerated with cargo-about 0.9.0), and the example `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. RELEASED_THROUGH stays 12: migration 12 is still the last one, so 1.0.0 carries the catalog of 0.1.15 and freezes nothing new. Upgrade manual: - Behavior Changes by Release gets a v1.0.0 entry for ExtendDB#945: the Cassandra backend reads and writes at LOCAL_QUORUM where 0.1.15 ran many of them at ONE, so a request fails with HTTP 500 while fewer than a quorum of its keyspace's replicas are up. It says what to do before upgrading: a replication factor of 3, as cassandra-setup.md describes. - A v1.0.0 entry for ExtendDB#1003. Without key_file the stored format and the catalog key stay as they are, and 0.1.15 and 1.0.0 each read the access keys the other wrote. serve and the backup commands refuse a catalog key that is not 32 bytes in base64, where 0.1.15 started and failed every signed request with HTTP 500; the entry says how to check the key before upgrading. The key moves into a locked key store, with a warning when the memlock limit is too low. key_file and the encryption-key commands are opt-in and link to the admin guide. - The rollback section of ExtendDB#1003 now gives the PostgreSQL refusal of 0.1.15 on a switched catalog: the encrypted connection string row stops it with exit status 1 before the missing key does. - Current Status, the General Upgrade Procedure and the Rollback Procedure cover 0.1.15 to 1.0.0, with the Cassandra step, the key check, and the rollback after encryption-key switch. Current Status says which of its paragraphs are for 0.1.14 and earlier and that the backup store notes apply to every deployment. - A v0.1.15 entry for the request validation of ExtendDB#619, ExtendDB#620, ExtendDB#830 and ExtendDB#1000, which had none. It says the expression depth limit is ExtendDB's own. - The rollback to 0.1.14 or earlier states what a binary of those releases does on a migrated catalog, as measured on PostgreSQL with 0.1.14 and 0.1.10: exit status 1, "invalid catalog version '12'". docs/versioning.md: the 0.1.x releases get no more fixes. The Docker Hub pages name 0.1.15 as the first keyless-signed release. docker/README-mongodb.md ran extenddb/extenddb-mongodb:0.1.8; it now runs X.Y.Z, as the other image READMEs do. doc_version_literals now reads docker/ as well, so a stale image tag there fails it. It reports each image tag once, and skips another project's image tag and a link to a release. The npm launcher test now checks that the launcher refuses the release line before an X.0.0 launcher, which it skipped at patch 0. Signed-off-by: Scott Robinson <robinnsc@amazon.com>
This branch changes two ImportTable answers that an existing client can see. A file of lines without an Item member imported its lines, and now it imports nothing. A file with a line the import cannot read answered HTTP 400 and left the new table empty. Now the request answers HTTP 200 with ImportStatus FAILED, and the items before the line stay imported. The upgrade manual gets a v1.1.0 entry for both changes, as the earlier ImportTable change of #620 has an entry.
What
This PR checks the
NandNSvalues on every key and item path below, with the text DynamoDB gives on each path. Main checked only the PutItem item and UpdateItem's update values. On the other paths, main stored or looked up anNvalue such asabcor1E126as written.1 validation error detected:and the number messageExpressionAttributeValues1 validation error detected:and the number messageExpected(ValueandAttributeValueList)1 validation error detected:and the number messageNSmembers, nestedLandM) and delete keysExpressionAttributeValues(on Put and Delete only with aConditionExpression)A refused batch or transaction writes nothing. Main stored the whole request, invalid values included.
Details of this round:
validate_number_i32_scale).ExpressionAttributeValuesnumbers no longer get theExpressionAttributeValues contains invalid value: <message> for key :vwrapper. This changes main's UpdateItem text too.NanswersThe parameter cannot be converted to a numeric value:with the colon on every path in the table except BatchWriteItem and ImportTable. BatchWriteItem leaves out the colon.ExpressionAttributeNamesname before a bad value number. TransactWriteItems reports aClientRequestTokenover 36 characters first. An item with both an over-long attribute name and a bad number gets the name error here. DynamoDB gives either error for the same request (counts below).import_rowandarithmetic_operandreturn aNumberFaultenum. They no longer sort errors by message text.Nthat DynamoDB cannot store compares as another type, so only<>is true. fix(import): check the numbers in each ImportTable row as the service does #804 checks the numbers in ImportTable rows.tests/test_backup_job.pystored items with invalid numbers through BatchWriteItem, TransactWriteItems, UpdateItem and ImportTable, and those paths refuse them now. Since 0daa2b8, the tests write those items straight into each backend's storage and check the same backup failure.Not changed here:
KeyConditions,QueryFilter,ScanFilter,ExclusiveStartKeyand theirExpressionAttributeValues(BatchWriteItem, TransactWriteItems and other operations store N values that fail number validation as written #618, fix(query): check Query values against the key schema and the number rules #544, fix(scan): check the numbers in ExpressionAttributeValues as the service does #562).0E126and0.0E-130stay accepted as0. DynamoDB refuses them (BatchWriteItem, TransactWriteItems and other operations store N values that fail number validation as written #618).NSwith two equal malformed members answers the duplicates error.1 validation error detected:prefix, and DynamoDB adds it #960). The token message keepsclientRequestToken(TransactWriteItems: the token length refusal names clientRequestToken, and DynamoDB now writes ClientRequestToken #959). PartiQL keeps its own reader (PartiQL: check_number reports the digit count before the magnitude, and DynamoDB reports the magnitude first #958).Why
Part of #618.
DynamoDB refuses these values, so ExtendDB has to refuse them with the same text. The service's answers changed during the review. On 9 Nov, BatchWriteItem read a 32-bit exponent. On 11 Nov, it read a 64-bit exponent like the other item operations. The expected answers in the tests come from DynamoDB in us-east-1, except where a test comment names a choice. Each request went out at least twice and got the same answer each time, unless a count says otherwise.
Measured on 11 Nov 2026, between 06:34 and 09:06 UTC:
10E2147483647and1E9223372036854775807answer Number overflow.1E-9223372036854775808answers Number underflow.1E9223372036854775808cannot be converted.10E2147483647and1E2147483648six times each, with Number overflow every time.abcand1E2147483648inExpectedanswer the prefixed number message on PutItem, DeleteItem and UpdateItem, ahead of the condition.ExpressionAttributeValuesnumbers with no wrapper. This holds forabc,12e,1E126, an emptyNand numbers insideM,LandNS.1E2147483648gave the name error 6 times and the number error 2 times on PutItem (8 sends). BatchWriteItem gave the same counts. TransactWriteItems gave 8 and 4 (12 sends), and 2 and 6 with the attributes in the other order (8 sends).1E2147483648and1E-2147483648ended their files withExpected a valid numeric. Remainder of the file will not be processed.and the import skipped1E2147483647as Number underflow. A file whose only refused row had a number key on a string-key table ended FAILED with ItemValidationError, 2 rows imported and 1 error.The message forms and the other order rows come from the 27 Oct measurements in the wire tests.
Testing done
At the tip 47c32b9, with
nice -n 19andCARGO_BUILD_JOBS=2:cargo +1.97.0 fmt --all -- --check: clean.cargo +1.97.0 clippy --locked --all-targets --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooks -- -D warnings: exit 0. The other CI clippy command, withextenddb-engine/backup-test-hooks, gave exit 0 at 732ebee.cargo +1.97.0 test --locked -p extenddb-core --lib: 1,132 passed, 1 ignored.-p extenddb-engine --lib: 767 passed.devtools/run-tests --extenddb --rust-integration --filter number_validation, against a SQLite server: 61 passed.devtools/run-tests --extenddb --pytest --filter "number_validation or TestImportTableNumbers": 34 passed.For 0daa2b8, the changed backup tests passed 3 of 3 on SQLite, PostgreSQL and MongoDB, in local containers. The other MongoDB, PostgreSQL and Cassandra suites ran in CI only.
CI at 0daa2b8: 64 of 64 checks passed. The Rust unit test job passed on a rerun. Its first attempt failed two timing tests in
crates/cache, which this PR does not change:panicking_refresh_does_not_leak_inflight_flag(#910) andconcurrent_stale_hits_spawn_only_one_refresh.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
Nvalue that DynamoDB refuses now gets a ValidationException on the paths above. Main stored or looked up such a value as written.ExpressionAttributeValuesnumber loses theExpressionAttributeValues contains invalid value: ... for key :vwrapper.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.