Repository navigation
fix: a finite-but-huge LRC timestamp could still overflow to OverflowError - #12
Merged
Merged
Conversation
…Error Same latent bug just found and fixed in the lyrics_karaoke plugin's copy of this code (feedBack-plugin-lyrics-karaoke#9 review): callers gate _lrc_timestamp() calls on math.isfinite(t), but that alone doesn't catch a value like 1e307 -- a real, finite double whose *scaled* form (1e307 * 100 = 1e309) exceeds the max representable double and becomes inf, so round() on the scaled value raised OverflowError instead of the clean skip the finiteness check was meant to guarantee. _lrc_timestamp() now checks the scaled (centisecond) value for finiteness too, raising ValueError instead of letting round() overflow. _format_lrc() and _format_lrc_word_level() now catch that ValueError and skip the segment/word, consistent with their existing malformed- input handling, rather than letting it propagate as a 500. This PR (#11) already merged before this bug was found, so this branch was restarted from main per the merged-PR branch-recovery convention. Bumped plugin.json to 1.1.4. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (3 files)
Reviewed by gpt-5.6-sol-discounted · Input: 24 · Output: 2.8K · Cached: 178.2K |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Reviewed the full diff of the single-commit PR — the _lrc_timestamp scaled-overflow guard, the matching ValueError skip handling in both LRC formatters, the two new regression tests, and the plugin.json version bump.
_lrc_timestampnow checks the scaled centisecond value for finiteness and raisesValueErrorinstead of lettinground()raiseOverflowErroron finite values like1e307that overflow once multiplied by 100._format_lrcand_format_lrc_word_levelcatch thatValueErrorand skip the offending segment/word, consistent with their existing malformed-input handling. All callers of_lrc_timestampare covered; there are no other call sites.tests/test_helpers.pyadds two regression tests; I verified both genuinely fail against the pre-fix code (OverflowError: cannot convert float infinity to integer) and pass against the fix.
Big Pickle (free) | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Same latent bug just found and fixed in the
lyrics_karaokeplugin's copy of this code (feedBack-plugin-lyrics-karaoke#9 review): callers gate_lrc_timestamp()calls onmath.isfinite(t), but that alone doesn't catch a value like1e307— a real, finite double whose scaled form (1e307 * 100 = 1e309) exceeds the max representable double and becomesinf, soround()on the scaled value raisedOverflowErrorinstead of the clean skip the finiteness check was meant to guarantee._lrc_timestamp()now checks the scaled (centisecond) value for finiteness too, raisingValueErrorinstead of lettinground()overflow._format_lrc()and_format_lrc_word_level()now catch thatValueErrorand skip the segment/word, consistent with their existing malformed-input handling, rather than letting it propagate as a 500.This PR's predecessor (#11) already merged before this bug was found, so this branch was restarted from
mainper the merged-PR branch-recovery convention.Testing
Added regression tests (
test_lrc_timestamp_rejects_a_finite_value_that_overflows_when_scaled,test_format_lrc_skips_a_finite_value_that_overflows_when_scaled) — verified both fail against the pre-fix code (OverflowError) and pass against the fix. Full suite:pytest tests/— 28 passed.Bumped
plugin.jsonto1.1.4.🤖 Generated with Claude Code
https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy
Generated by Claude Code