Skip to content

fix: a finite-but-huge LRC timestamp could still overflow to OverflowError - #12

Merged
cchacs merged 1 commit into
mainfrom
claude/lyrics-sync-overflow-fix
Sep 9, 2026
Merged

cchacs merged 1 commit into
mainfrom
claude/lyrics-sync-overflow-fix

Conversation

@cchacs

@cchacs cchacs commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

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's predecessor (#11) already merged before this bug was found, so this branch was restarted from main per 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.json to 1.1.4.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HVxQShyx8Mrqe1GKNstjHy


Generated by Claude Code

…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
@kilo-code-bot

kilo-code-bot Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • plugin.json
  • routes.py
  • tests/test_helpers.py

Reviewed by gpt-5.6-sol-discounted · Input: 24 · Output: 2.8K · Cached: 178.2K

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ 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_timestamp now checks the scaled centisecond value for finiteness and raises ValueError instead of letting round() raise OverflowError on finite values like 1e307 that overflow once multiplied by 100.
  • _format_lrc and _format_lrc_word_level catch that ValueError and skip the offending segment/word, consistent with their existing malformed-input handling. All callers of _lrc_timestamp are covered; there are no other call sites.
  • tests/test_helpers.py adds 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.

Pullfrog  | View workflow run | Using Big Pickle (free) | 𝕏

@get-flashbacks get-flashbacks deleted a comment from coderabbitai Bot Sep 9, 2026
@cchacs
cchacs merged commit af49ef9 into main Sep 9, 2026
5 checks passed
@cchacs
cchacs deleted the claude/lyrics-sync-overflow-fix branch September 9, 2026 03:30
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