Repository navigation
fix(core): range check number exponents as DynamoDB does - #619
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
There was a problem hiding this comment.
@LeeroyHannigan I checked this change against live DynamoDB. The panic from #616 is fixed, and
the wrong message in release builds is fixed. No value panicked a debug build,
and no value wrapped on the paths that check numbers.
Two values still get the wrong message. I measured each one on live DynamoDB in
us-east-1. I sent each value two times, and both times gave the same answer.
-
A zero with the exponent at the largest 64-bit value.
PutItem with a non-key attribute
{"N": "0E9223372036854775807"}.
Live DynamoDB answersNumber underflow. This change answersNumber overflow.The neighbors show the edge.
0E9223372036854775806answersNumber overflow,
and0.0E9223372036854775807answersNumber overflow. Only the exponent at
exactly the largest 64-bit value, with no fraction, answersNumber underflow. -
More than 38 significant digits together with an out-of-range magnitude.
PutItem with
{"N": "1234567890123456789012345678901234567890E9223372036854775768"}.
Live DynamoDB answersNumber overflow. This change answers
Attempting to store more than 38 significant digits in a Number.Live DynamoDB checks the magnitude before the digit count. The same value with
the exponent one lower (...767) answers the digit-count message on both. So
when the magnitude is out of range, the overflow or underflow message comes first.
Please change the code to match live DynamoDB for both values, and add the
measured values as test cases. The 64-bit exponent range is new in this change,
so both values reach these paths for the first time here.
The branch is a long way behind main. Please rebase it on current main so the
checks run against the current tree.
I will approve once both values match live DynamoDB and the branch is rebased.
Main has not changed crates/core/src/validation/number.rs or tests/rust/src/number_validation.rs since this branch was cut. The merge has no conflicting file and no edit outside the merge itself. The core crate and its tests compile on the merged tree.
DynamoDB computes the exponent of a number's normalized form, the order of magnitude plus one, in 64 bits. Two answers at the edge of that range differed from ExtendDB's. PutItem in us-east-1 gave each value below the same answer on two sends, on 9 or 10 Nov 2026. A zero whose exponent is i64::MAX, with no fraction digit, is an underflow: the sum wraps to a negative exponent. A fraction digit lowers the exponent before the sum. So 0E9223372036854775807 is an underflow, while 0E9223372036854775806 and 0.0E9223372036854775807 are overflows. For a nonzero value whose sum is above i64::MAX, DynamoDB reports the overflow before it counts the digits. Forty digits with E9223372036854775768, E9223372036854775769 and E9223372036854775807 (an order of magnitude of i64::MAX, i64::MAX + 1 and i64::MAX + 39) are overflows. The same digits with E9223372036854775767 are too many digits. The one-digit 1E9223372036854775807 and 10E9223372036854775807 are overflows as well. validate_and_normalize_number now computes the order of magnitude before the digit count and applies both rules. The measured values are unit tests in number.rs and wire tests in tests/rust, which check the full message text.
|
@eliseong Both values now answer as you measured. 39a41fb computes the exponent of the normalized form, the order of magnitude plus one, in 64 bits:
On 2026-11-10 I measured two more values the same way. The 40 digits with I merged main at 887b6e2 (e80d018) instead of rebasing, which avoids a force push. CI now runs against current main. Main had not changed either file, and the merge has no conflicts. |
|
@LeeroyHannigan Thank you. F1 and F2 now match live DynamoDB. I confirmed both on live, two
The large side of the exponent range is correct now. The small side has the
This is the same rule as the overflow side, so please add the matching check for I will approve once the small-side value matches live DynamoDB. |
DynamoDB answers Number underflow before it counts the digits when the normalized exponent is below the smallest 64-bit value. The normalized form is 0.d * 10^n, with the first nonzero digit right after the point. At that value, and above it, a number with more than 38 digits gets the 38-digit message. This is the mirror of the large side, where the overflow comes first once the exponent is above the largest 64-bit value. PutItem in us-east-1 answered these twelve values on 2026-11-10, two sends each, with the same answer both times. The digits are 1234567890123456789012345678901234567891 (40) and 123456789012345678901234567890123456789 (39). Each fraction zero before the digits lowers the normalized exponent by one. Number underflow, at i64::MIN - 1, i64::MIN - 2 and i64::MIN - 40: .0<40 digits>E-9223372036854775808 .00<40 digits>E-9223372036854775807 .00<40 digits>E-9223372036854775808 .<40 zeros><40 digits>E-9223372036854775808 .0<39 digits>E-9223372036854775808 -.0<40 digits>E-9223372036854775808 The 38-digit message, at i64::MIN and at i64::MIN + 40: .<40 digits>E-9223372036854775808 .0<40 digits>E-9223372036854775807 .00<40 digits>E-9223372036854775806 <40 digits>E-9223372036854775808 .<39 digits>E-9223372036854775808 -.<40 digits>E-9223372036854775808 The six underflow rows fail on the current code, which answers the digit count for them. The fix follows in the next commit. The date notes in both test files now name the values whose date differs from their section's. 0E9223372036854775806 carries 2026-10-27. The rows of the two newest tests carry 2026-11-10.
The large side of the exponent range answers Number overflow before the digit count once the normalized exponent is above i64::MAX. The normalized form is 0.d * 10^n. The small side answered the digit count for every number with more than 38 digits, whatever its exponent. DynamoDB answers Number underflow before the digit count once that exponent is below i64::MIN. Add the mirror check next to the overflow check. A number with at most 38 digits this far down was an underflow already, through the range check. Only numbers with more digits change their answer. PutItem in us-east-1 answered the twelve values of the previous commit on 2026-11-10, two sends each, with the same answer both times. The normalized exponents i64::MIN - 1, i64::MIN - 2 and i64::MIN - 40 get Number underflow. The exponents i64::MIN and i64::MIN + 40 get the 38-digit message. This holds with 40 digits, with 39 digits and with a minus sign. The six underflow rows pass with this change, and the six digit-count rows keep their answer.
pdf-amzn
left a comment
There was a problem hiding this comment.
I agree with @eliseong's open point: I measured the small-side values too, and they still answer the digit-count message here. The other edge spellings I measured all match. What follows is AI generated:
Blocking: crates/core/src/validation/number.rs:118-124. There is no small-side counterpart to normalized_exponent_exceeds_i64. Measured 2026-11-10 19:39 UTC (us-east-1, PutItem non-key N, each value twice):
- .01234567890123456789012345678901234567891E-9223372036854775808: DynamoDB answers Number underflow, this PR answers the digit-count message.
- .001234567890123456789012345678901234567891E-9223372036854775807: same.
- -.01234567890123456789012345678901234567891E-9223372036854775808: same.
- .1234567890123456789012345678901234567891E-9223372036854775808 (normalized exactly i64::MIN): the digit-count message on both, correctly.
Fix: before the digit-count check, add if magnitude_exp + 1 < i128::from(i64::MIN) { return Err(underflow_err()); }, strict < to mirror > i64::MAX. Add unit rows next to magnitude_at_i64_max_is_an_overflow_before_the_digit_count and wire rows next to put_item_magnitude_at_i64_max_is_overflow_before_digit_count, with the edge value as the digit-count row. Update the doc comment on normalized_exponent_exceeds_i64 (line 150), or fold both sides into one helper.
Measured, no change needed: zeros on the small side. If DynamoDB wrapped the zero's point offset in 64 bits on this side as it does on the large side, 0.00E-9223372036854775808 would answer overflow. It doesn't. 0E-9223372036854775808, 0E-9223372036854775807, 0.0E-9223372036854775808, 0.00E-9223372036854775808, 0.000E-9223372036854775807 and 0.000E-9223372036854775808 all answer Number underflow on DynamoDB, and this PR matches.
Should-fix: the wire tests in tests/rust/src/number_validation.rs are dual-target, but CI only runs them against ExtendDB. I ran cargo test number_validation in tests/rust against real DynamoDB: all four new i64-edge tests pass there. Of the older tests, put_item_exponent_near_i32_limits_is_overflow_or_underflow and update_item_accepts_valid_number_in_expression failed with transport errors (no service answer; "runtime dropped the dispatch task"), which looks like the static CLIENT in test_base.rs being reused across #[tokio::test] runtimes. Not this PR's to fix. Separately, update_item_rejects_malformed_number_in_expression (unchanged here) failed for real: for 12e DynamoDB answered 1 validation error detected: The parameter cannot be converted to a numeric value: 12e, without the ExpressionAttributeValues contains invalid value wrapper the test expects. That's a question for main, not this PR.
Nit-or-follow-up: these spellings match DynamoDB on this PR (same measurement run) but have no test row, so a later refactor could change them unnoticed. Worth adding: -0E9223372036854775807, +0E9223372036854775807 and 0.E9223372036854775807 (underflow); 1E+09223372036854775807, -1E9223372036854775807 and 1E0000000000000000000002147483648 (overflow); 1E-09223372036854775808 (underflow).
Nit-or-follow-up: crates/core/src/validation/number.rs:145-148. digit_count uses i128::try_from(len).unwrap_or(i128::MAX) with the comment "always fits". The fallback can never run, and would answer wrongly if it did. .expect("usize fits in i128") states the invariant.
Nit-or-follow-up: crates/core/src/validation/number.rs:130. map_err(|_| overflow_err()) can't be reached, per the comment above it. If it were, it would hide a logic error as a user-facing overflow. Consider .expect(...).
|
my comment is out of date. rereviewing |
|
Thanks. I pushed ebc5287 with the small side. A nonzero number now answers I measured it on live DynamoDB on 2026-11-10, two sends each, with the same answer both times. Six values below the edge answer The unit test and the wire test both carry the twelve rows. The new rows failed before the fix and pass at ebc5287, and the description has the new table. |
|
Nothing blocking from my side, I'll let Elise approve or not :) From Kiro I checked the new head, ebc5287: It adds normalized_exponent_is_below_i64, which is the same strict magnitude_exp + 1 < i64::MIN check the review suggested. It adds a unit test magnitude_below_i64_min_is_an_underflow_before_the_digit_count and a wire test put_item_magnitude_below_i64_min_is_underflow_before_digit_count. I rebuilt it in the worktree. The core number tests pass, and all 17 probe values now match DynamoDB results. That includes the three that differed before. Still open: The seven measured spellings still have no test rows. The two nits about fallbacks that can never run. |
eliseong
left a comment
There was a problem hiding this comment.
LGTM
The panic from #616 is fixed, and no number value wraps on the paths that check
numbers. I ran a debug build and sent exponents at the i32, i64, and i128 edges,
large mantissas, zeros with large exponents, and the same values as keys and as
attributes. None dropped the connection.
The number messages now match live DynamoDB at both ends of the 64-bit exponent
range. I measured these on live, two sends each with the same answer both times.
0E9223372036854775807answersNumber underflow, and0E9223372036854775806
answersNumber overflow.- A value with more than 38 digits and an order of magnitude above i64::MAX
answersNumber overflowbefore the digit count. The small side now matches
too: the same value below i64::MIN answersNumber underflowbefore the digit
count, and the value at the edge answers the digit-count message.
The branch merges clean on current main.
Main is 245 commits ahead of the merge base (817b240), up to 9c3fbfb. Six files conflicted. - crates/core/src/validation/number.rs: main's reader, from #619 as merged, with this branch's operations module and magnitude limits. The merge drops check_zero_magnitude, since main's zero handling gives the same answers. The zero test keeps two rows that main lacks, 0.00E-9223372036854775808 and 0.000E-9223372036854775808 (underflow on GetItem, measured 2026-10-27), and drops two rows that main's zero_with_exponent_at_i64_max_is_an_underflow covers. - crates/core/src/expression/resolver.rs: main's two new ExpressionMaps fields and this branch's parsed_numerics type and comment. - crates/engine/src/import_export.rs: main's AttributeNameRequestForm argument and this branch's log fields. - crates/engine/src/put_item.rs: main's attribute name size checks, then this branch's item number check. - crates/engine/src/transact_write_items.rs: the ClientRequestToken check, then main's attribute name size checks for every action, then the number check of each action after the handler prepares it. - tests/rust/src/number_validation.rs: main's file, which holds this branch's rows and three later tests. crates/engine/src/batch_write_item.rs merged without a conflict, with the number check ahead of main's attribute name size checks. The merge moves the number check after them, as in PutItem and TransactWriteItems. delete_item.rs and update_item.rs merged without a conflict: they check the key's numbers, then main's attribute name sizes, then the numbers in ExpressionAttributeValues. Measured in us-east-1 on 11 Nov 2026: an item held a 65,536-byte attribute name and the number 1E2147483648. PutItem, BatchWriteItem and TransactWriteItems gave either refusal on repeated sends. TransactWriteItems reported a 37-character ClientRequestToken ahead of both.
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>
What
#394 (34aa2df, backup format v1) moved the three exponent sums in
validate_and_normalize_numberto saturatingi64arithmetic, which fixed the overflow #616 reports. Main 817b240 answers the first three rows of the first table below as DynamoDB does. On abf8082 a debug build panicked on the first and third. Main still parses the exponent as ani32, so an exponent between thei32andi64limits is refused ascannot be converted to a numeric value, where DynamoDB answersNumber overfloworNumber underflow. This PR carries thei64exponent, the zero check that goes with it, and DynamoDB's answers at both ends of thei64range.In
crates/core/src/validation/number.rs:i64, as DynamoDB reads it, and the sums are done ini128, where none of them can overflow. This replaces feat(core): backup format v1: streaming data files, sidecar manifest hash, typed backup ARN [backup/restore 3/4] #394's saturatingi64sums and itslen_i64helper withdigit_countandcheck_magnitude.1E2147483648is nowNumber overflowand1E-2147483649Number underflow. Main answerscannot be convertedfor both.1E9223372036854775808is stillcannot be converted, as on DynamoDB.i32is range checked (0E2147483648isNumber overflow). Main refuses those zeros ascannot be converted, so the set of refused inputs does not change.normalized_exponent_exceeds_i64, reports when that sum leaves thei64range. For a zero, the sum leaves the range only when the exponent is exactly9223372036854775807with no fraction digit. The sum then wraps to a negative exponent, and the answer isNumber underflow. A fraction digit lowers the exponent before the sum, so0.0E9223372036854775807staysNumber overflow. For a nonzero value, the order of magnitude is now computed before the digit count. A sum above the range then answersNumber overflow, and the digit count does not run.i64minimum answersNumber underflow, and the digit count does not run. The helpernormalized_exponent_is_below_i64reports that case, and its check runs after the overflow check and before the digit count. A nonzero value with at most 38 digits and such an exponent was already an underflow throughcheck_magnitude. Relative to 39a41fb, only nonzero values with more than 38 digits get a different answer. The zero path does not change.i32is still accepted as0. DynamoDB refuses0E126and0.0E-130. But a zero refused here keeps its raw spelling inAttributeValue. Afterwards, only the PutItem item and UpdateItem's ExpressionAttributeValues and AttributeUpdates go through the number check. BatchWriteItem, TransactWriteItems, UpdateItem's key and the other operations would then store and look up0E126as a key separate from0. BatchWriteItem, TransactWriteItems and other operations store N values that fail number validation as written #618 covers that validation gap and the zero check together. The unit testzero_with_i32_exponent_stays_accepted_until_618marks the place to change.The PR keeps the test #394 added in
number.rs,exponents_at_the_ends_of_i32_classify_the_magnitude.The branch merges main at 887b6e2 (e80d018). Main had not changed
number.rsortests/rust/src/number_validation.rssince the branch was cut, and the merge has no conflicting file.Measured
The DynamoDB column is PutItem with a non-key
Nattribute in us-east-1. Each value was sent twice, with the same answer both times. In the first table, the four rows above the last one were measured on 2026-11-09, and the last row on 2026-11-10. The other rows were measured on 2026-10-27. The ExtendDB columns are PutItem with the same attribute against dev-mode SQLite servers. Main 817b240 and the branch head of that day ran on 2026-10-30. For the last five rows, this branch ran at 39a41fb on 2026-11-10.10E2147483647,12E2147483647,100E2147483647,-10E2147483647Number overflowNumber overflowNumber overflow1E+2147483647,0.1E2147483647Number overflowNumber overflowNumber overflow1.5E-2147483648,-1.5E-2147483648,0.01E-2147483648Number underflowNumber underflowNumber underflow1E2147483648,1E4294967296,1E9223372036854775807Number overflowcannot be convertedNumber overflow1E-2147483649,1E-9223372036854775808Number underflowcannot be convertedNumber underflow1E9223372036854775808,1E-9223372036854775809cannot be convertedcannot be convertedcannot be converted0E2147483648,0E9223372036854775806Number overflowcannot be convertedNumber overflow0E-9223372036854775807,0E-9223372036854775808Number underflowcannot be convertedNumber underflow0E126,0.0E-130Number overflow,Number underflow00(#618)0E9223372036854775807Number underflowcannot be convertedNumber underflow0.0E9223372036854775807Number overflowNumber overflow1234567890123456789012345678901234567890) withE9223372036854775768Number overflowNumber overflowE9223372036854775767E9223372036854775769orE9223372036854775807Number overflowNumber overflowThe second table covers the small side of the range. The DynamoDB column was measured on 2026-11-10 with the same PutItem request in us-east-1. Each value was sent twice, with the same answer both times. The ExtendDB columns are PutItem against dev-mode SQLite servers, run on 2026-11-10. The 39a41fb column ran on a server built from 58b177f, which differs from 39a41fb only in tests. The ebc5287 column ran on a server built from ebc5287. The 40 digits are
1234567890123456789012345678901234567891, and the 39 digits are123456789012345678901234567890123456789. The column n is the exponent of the normalized form0.d1d2... * 10^n, where d1 is the first nonzero digit. That exponent is the order of magnitude plus one. Each zero between the point and the digits lowers n by one. Values with n = i64::MIN - 1, i64::MIN - 2 and i64::MIN - 40 answerNumber underflow. Values with n = i64::MIN and i64::MIN + 40 answer the message for more than 38 digits. The answers are the same with 39 digits and with 40 digits, and with both signs..01234567890123456789012345678901234567891E-9223372036854775808Number underflowNumber underflow.001234567890123456789012345678901234567891E-9223372036854775807Number underflowNumber underflow.001234567890123456789012345678901234567891E-9223372036854775808Number underflowNumber underflow.00000000000000000000000000000000000000001234567890123456789012345678901234567891E-9223372036854775808(40 zeros)Number underflowNumber underflow.0123456789012345678901234567890123456789E-9223372036854775808(39 digits)Number underflowNumber underflow-.01234567890123456789012345678901234567891E-9223372036854775808Number underflowNumber underflow.1234567890123456789012345678901234567891E-9223372036854775808.01234567890123456789012345678901234567891E-9223372036854775807.001234567890123456789012345678901234567891E-92233720368547758061234567890123456789012345678901234567891E-9223372036854775808.123456789012345678901234567890123456789E-9223372036854775808(39 digits)-.1234567890123456789012345678901234567891E-9223372036854775808DynamoDB starts each of these messages with
1 validation error detected:and ExtendDB does not. This PR does not change that difference.Why
Closes #616. DynamoDB reads a number's exponent as a 64-bit value, and main reads it as a 32-bit value.
Testing done
number.rs: eight new tests, 29 tests in the module, all passing on ebc5287. On 39a41fb the module had 28 tests, all passing. At 58b177f, which adds the eighth test to the code of 39a41fb, 28 tests pass and one fails.magnitude_below_i64_min_is_an_underflow_before_the_digit_countfails at its first row,.01234567890123456789012345678901234567891E-9223372036854775808, with the message for more than 38 digits. Run against main 817b240'snumber.rs, two of the first five new tests fail oncannot be converted:exponent_is_read_as_i64at1E2147483648andzero_with_exponent_outside_i32_is_range_checkedat0E2147483648.exponent_near_i32_limits_is_an_overflow_or_underflow, which failed on abf8082 with the overflow panic, passes on main since feat(core): backup format v1: streaming data files, sidecar manifest hash, typed backup ARN [backup/restore 3/4] #394. On the merge commit e80d018, the two tests that 39a41fb added fail with the answers the review reported.zero_with_exponent_at_i64_max_is_an_underflowgetsNumber overflowthere.magnitude_at_i64_max_is_an_overflow_before_the_digit_countgets the message for more than 38 digits.tests/rust/src/number_validation.rs: six new tests. Against a dev-mode SQLite server built from ebc5287, thenumber_validationfilter passes 15 of 15 with--test-threads=1. Against a server built from 58b177f, 14 pass andput_item_magnitude_below_i64_min_is_underflow_before_digit_countfails at the same first row with the message for more than 38 digits. Against a server built from 39a41fb, the filter passed 14 of 14. The filter also matches main'supdate_item_number_validation.rs. In an earlier parallel run, 5 of the 14 failed with a transport error (DispatchGone) and no server error. The failing tests came from this branch and from main. Against main 817b240,put_item_exponent_near_i32_limits_is_overflow_or_underflowfails at1E2147483648andput_item_zero_with_exponent_outside_i32_is_rejectedat0E2147483648.put_item_exponent_outside_i64_is_malformedpasses on main too.cargo +1.97.0 fmt --all -- --checkis clean. Both clippy runs are clean with-D warnings:cargo +1.97.0 clippy --locked --all-targets --features extenddb-storage-cassandra/test-hooks,extenddb-storage-mongodb/test-hooksandcargo +1.97.0 clippy --locked --all-targets --features extenddb-engine/backup-test-hooks.cargo fmt --all -- --checkandcargo +1.97.0 clippy --locked -p extenddb-core --all-targets -- -D warningsare clean on 39a41fb.cargo test --locked -p extenddb-core --libpassed 1089 tests, with 1 ignored, one revision earlier. That revision differs from 39a41fb only in tests and comments. The passing tests include feat(core): backup format v1: streaming data files, sidecar manifest hash, typed backup ARN [backup/restore 3/4] #394'sexponents_at_the_ends_of_i32_classify_the_magnitude,doc_examples_normalize_as_statedandexponent_at_the_end_of_i32_is_refused_as_an_overflow.0E126,-0E126and0.0E-130as keys and attributes. It covered GetItem, Query, BatchGetItem, BatchWriteItem, TransactWriteItems, UpdateItem and DeleteItem. The output on the branch was the same as on main abf8082. For those zeros this branch and main 817b240 both return0. The only check this PR adds on that path applies to an exponent outsidei32.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
None.
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.