Skip to content

events: Integer returns the documented range error instead of a wrong number - #640

Open
lenamonj wants to merge 1 commit into
aws:mainfrom
lenamonj:attributevalue-integer-range-error
Open

events: Integer returns the documented range error instead of a wrong number#640
lenamonj wants to merge 1 commit into
aws:mainfrom
lenamonj:attributevalue-integer-range-error

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 7, 2026

Copy link
Copy Markdown

DynamoDBAttributeValue.Integer documents that a value outside int64 comes back as the maximum magnitude int64 of the matching sign with err.Err = ErrRange. strconv.ParseInt returns exactly that, but Integer treats every parse error as a decimal string and retries with ParseFloat, which succeeds and drops the error: on amd64 NewNumberAttribute("99999999999999999999").Integer() returns -9223372036854775808, nil, the wrong sign and no error. DynamoDB numbers carry up to 38 digits, so this is ordinary content.

The change keeps the ParseFloat fallback for syntax errors only and saturates with ErrRange when a parsed float is outside int64 as well; "123.45" still returns 123. The new test fails on main and passes with the change. go test -race ./events/ and golangci-lint v2.13.1 are clean.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.38%. Comparing base (6800157) to head (7a9ecb2).

Files with missing lines Patch % Lines
events/attributevalue.go 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #640   +/-   ##
=======================================
  Coverage   82.38%   82.38%           
=======================================
  Files          36       36           
  Lines        1419     1425    +6     
=======================================
+ Hits         1169     1174    +5     
- Misses        247      248    +1     
  Partials        3        3           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants