Skip to content

compat: allow the tag option to round a negative fraction away from zero - #14

Merged
pscheid92 merged 1 commit into
mainfrom
fix-compat-negative-fraction
Nov 12, 2026
Merged

pscheid92 merged 1 commit into
mainfrom
fix-compat-negative-fraction

Conversation

@pscheid92

Copy link
Copy Markdown
Owner

The scheduled fuzz run on main failed on "-PT0,0000000000002H": jsonduration reads 0, the format tag option reads -1ns.

This is the negative twin of a difference already listed in TestDifferencesFromFormatTag: jsonduration truncates fractions of hours and minutes exactly, encoding/json/v2 rounds them through float64. The test allowed it only as want-got == 1, which holds for positive durations alone.

  • The allowance is sign-aware: the tag option must be exactly 1ns further from zero, on the same side.
  • A row for the negative case in TestDifferencesFromFormatTag, a fuzz seed, and the failing corpus file.

The library is unchanged. just compat, just lint and a 60s just compat-fuzz on this target pass.

The scheduled fuzz run found "-PT0,0000000000002H": jsonduration truncates it to 0, the format tag option rounds it
through float64 to -1ns. That is the listed difference for fractions of hours and minutes, but the test only allowed
it for positive durations. The library is unchanged.
@pscheid92
pscheid92 merged commit d495e46 into main Nov 12, 2026
11 checks passed
@pscheid92
pscheid92 deleted the fix-compat-negative-fraction branch November 12, 2026 21:04
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.

1 participant