fix(core/protocols): handle JSON exponent notation in jsonReviver#8226
Merged
Conversation
kuhe
force-pushed
the
kuhe/fix/numeric
branch
4 times, most recently
from
July 24, 2026 22:49
e0c3e12 to
c20dd4f
Compare
The reviver incorrectly classified exponent-notation numbers (e.g. 1.784316439424E9) as precision-losing because numericString !== String(value) always fails for alternate notations. This caused deserialization failures for any awsJson response containing exponent-notation numbers, which AWS services emit for epoch-second timestamps (e.g. ECS createdAt). Fix: when the source contains exponent notation ([eE]) and the value is within safe integer bounds, normalize via String(Number(source)) and compare against String(value). If they match, the number round-trips exactly and is returned as a plain JS number. For values outside safe integer bounds with exponent notation: - Fractional (e.g. 1.23E100) → NumericValue (requires smithy-lang/smithy-typescript#2184) - Non-fractional (e.g. 1E19) → BigInt via Number() conversion Also fixes BigInt path to handle exponent notation (BigInt() doesn't accept '1E19' directly, so we normalize through Number() first). Fixes: #8224
smilkuri
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #8224, see also smithy-lang/smithy-typescript#2184
The
jsonReviverincorrectly classified exponent-notation numbers (e.g.1.784316439424E9) as precision-losing, becausenumericString !== String(value)always fails when the source uses exponent notation.