Skip to content

fix(gax-internal): error on non-finite numbers - #7427

Open
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:gax-internal-error-on-non-finite
Open

olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:gax-internal-error-on-non-finite

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Converting incoming protobuf numeric values into JSON values previously panicked when encountering a non-finite number, such as NaN or infinity. While protobuf wire formats allow non-finite floating-point numbers, standard JSON numeric representations only permit finite values.

Instead of panicking when an unrepresentable number arrives over the wire, return a conversion error so calling services and background tasks can safely catch, log, or ignore the invalid payload.

@olavloite
olavloite requested a review from a team as a code owner November 10, 2026 09:44

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves error handling in src/gax-internal/src/prost.rs by replacing a panic (expect) with proper error propagation (?) when converting non-finite floats (NaN or infinite) to JSON numbers. It also adds comprehensive unit tests to verify correct behavior for both finite and non-finite numbers across values, structs, and lists. I have no additional feedback to provide as the changes are robust and align with the repository's style guide regarding error handling.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.65%. Comparing base (779a055) to head (aeac845).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7427      +/-   ##
==========================================
- Coverage   98.65%   98.65%   -0.01%     
==========================================
  Files         334      334              
  Lines      145620   145673      +53     
==========================================
+ Hits       143657   143707      +50     
- Misses       1963     1966       +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.

Converting incoming protobuf numeric values into JSON values
previously panicked when encountering a non-finite number,
such as NaN or infinity. While protobuf wire formats allow
non-finite floating-point numbers, standard JSON numeric
representations only permit finite values.

Instead of panicking when an unrepresentable number arrives over
the wire, return a conversion error so calling services and
background tasks can safely catch, log, or ignore the invalid
payload.
@olavloite
olavloite force-pushed the gax-internal-error-on-non-finite branch from 8fc76e0 to aeac845 Compare November 10, 2026 10:33

This branch has not been deployed

No deployments
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