Skip to content

fix: return zero value for Int, Uint, and Dec when unmarshalling empty bytes#3221

Merged
masih merged 2 commits into
mainfrom
amir/plt-257-fix-no-op-empty-byte-handling-in-Int-Uint-Dec-Unmarshal
Apr 10, 2026
Merged

fix: return zero value for Int, Uint, and Dec when unmarshalling empty bytes#3221
masih merged 2 commits into
mainfrom
amir/plt-257-fix-no-op-empty-byte-handling-in-Int-Uint-Dec-Unmarshal

Conversation

@amir-deris

@amir-deris amir-deris commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Problem

When Int, Uint, or Dec protobuf Unmarshal methods received an empty byte slice, they returned without initializing the underlying *big.Int, leaving the struct in a nil/invalid state. This would cause panics on subsequent operations like Equal(), arithmetic, etc.

Fix

Return the proper zero value (ZeroInt(), ZeroUint(), ZeroDec()) when the input data is empty, rather than leaving the struct uninitialized.

Files Changed

  • sei-cosmos/types/int.goInt.Unmarshal
  • sei-cosmos/types/uint.goUint.Unmarshal
  • sei-cosmos/types/decimal.goDec.Unmarshal
  • Corresponding test files with coverage for the empty-bytes case

@amir-deris amir-deris changed the title Set the zero value for sei-cosmos int, unit and decimal type when unm… fix: return zero value for Int, Uint, and Dec when unmarshalling empty bytes Apr 9, 2026
@github-actions

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 10, 2026, 7:59 AM

@amir-deris amir-deris self-assigned this Apr 9, 2026
@amir-deris amir-deris requested review from bdchatham and masih April 9, 2026 17:22
@codecov

codecov Bot commented Apr 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.26%. Comparing base (1f4724d) to head (cff10bb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3221      +/-   ##
==========================================
+ Coverage   59.00%   59.26%   +0.26%     
==========================================
  Files        2065     2065              
  Lines      169422   169410      -12     
==========================================
+ Hits        99959   100398     +439     
+ Misses      60700    60261     -439     
+ Partials     8763     8751      -12     
Flag Coverage Δ
sei-chain-pr 87.97% <100.00%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-cosmos/types/decimal.go 87.33% <100.00%> (+0.77%) ⬆️
sei-cosmos/types/int.go 88.94% <100.00%> (+1.50%) ⬆️
sei-cosmos/types/uint.go 85.71% <100.00%> (+2.38%) ⬆️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@masih masih enabled auto-merge April 10, 2026 07:56
@masih masih added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 2dc6320 Apr 10, 2026
39 checks passed
@masih masih deleted the amir/plt-257-fix-no-op-empty-byte-handling-in-Int-Uint-Dec-Unmarshal branch April 10, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants