You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: DynamoDB numbers longer than 38 characters are deserialized to the wrong value #8512
TypeDeserializer (used by DynamoDBStreamEvent / StreamRecord.new_image and old_image) returns a Decimal equal to the stored number for any value DynamoDB accepts.
Current Behaviour
_deserialize_n decides whether a number is too long by counting characters after stripping leading zeros, then slices the string. The sign and the decimal point count as characters, and slicing off trailing zeros changes the magnitude. Valid numbers come back wrong, with no error:
1.234567890123456789012345678901234567, last digit dropped
110111111111111110000000000000000000000 (the value from #4845)
11011111111111111000000000000000000000, off by a factor of 10
12345678901234567890123456789012345678000
12345678901234567890123456789012345678, off by a factor of 1000
All four are within DynamoDB's 38 digits of precision, since trailing zeros don't count.
Code snippet
fromdecimalimportDecimalfromaws_lambda_powertools.shared.dynamodb_deserializerimportTypeDeserializerforvaluein [
"-12345678901234567890123456789012345678",
"1.2345678901234567890123456789012345678",
"110111111111111110000000000000000000000",
"12345678901234567890123456789012345678000",
]:
result=TypeDeserializer().deserialize({"N": value})
print(result, result==Decimal(value)) # False for every one
Possible Solution
Parse with Decimal(value) and, only when the coefficient has more than 38 digits, normalize() it with a 38-digit context so trailing zeros move into the exponent. The value stays the same and DYNAMODB_CONTEXT.create_decimal no longer raises Rounded, which was the original problem in #4845.
The two test_dynamodb_stream_record_deserialization_large_int* tests currently assert the truncated values and would need their expected values corrected. I have this ready with tests and can open a PR.
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
powertools-for-aws-oss-automation commented on Oct 2, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out our GitHub Discussions: Join the conversation
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Activity
boring-cyborg commentedon Oct 2, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
powertools-for-aws-oss-automation commentedon Oct 2, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out our GitHub Discussions: Join the conversation
powertools-for-aws-oss-automation commentedon Oct 2, 2026
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
github-actions commentedon Oct 15, 2026
This is now released under 3.36.0 version!