Skip to content

fix(wkt): panic in Duration deserialization - #6682

Merged
coryan merged 2 commits into
googleapis:mainfrom
coryan:fix-bug-6674
Sep 7, 2026
Merged

fix(wkt): panic in Duration deserialization#6682
coryan merged 2 commits into
googleapis:mainfrom
coryan:fix-bug-6674

Conversation

@coryan

@coryan coryan commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

When deserializing a Duration string with more than 9 fractional digits,
&pad[s.len()..] would panic with an out-of-bounds byte index.

When deserializing a Duration string with more than 9 fractional digits,
`&pad[s.len()..]` would panic with an out-of-bounds byte index.

@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 updates the Duration deserialization logic in src/wkt/src/duration.rs to handle fractional seconds exceeding 9 digits, adding validation for non-digit characters and empty nanoseconds, along with corresponding unit tests. The review feedback suggests optimizing the nanosecond parsing logic to avoid unnecessary heap allocations and string formatting overhead from format! by parsing the substring directly and mathematically scaling it.

Comment thread src/wkt/src/duration.rs Outdated
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.66%. Comparing base (86c2a65) to head (ed6ef8d).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6682   +/-   ##
=======================================
  Coverage   96.66%   96.66%           
=======================================
  Files         308      308           
  Lines       97778    97803   +25     
=======================================
+ Hits        94519    94544   +25     
  Misses       3259     3259           

☔ 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.

@coryan
coryan marked this pull request as ready for review September 7, 2026 17:50
@coryan
coryan requested a review from a team as a code owner September 7, 2026 17:50
@coryan
coryan merged commit 1c84807 into googleapis:main Sep 7, 2026
42 checks passed
@coryan
coryan deleted the fix-bug-6674 branch September 7, 2026 18:19
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