Skip to content

fix(segments): reject negative and non-finite durations - #7

Merged
joepetjr merged 1 commit into
mainfrom
fix/kc-1-validate-durations
Oct 1, 2026
Merged

joepetjr merged 1 commit into
mainfrom
fix/kc-1-validate-durations

Conversation

@joepetjr

Copy link
Copy Markdown
Contributor

Summary

boundaries_from_durations accepted negative, NaN and infinite durations. It built backwards or NaN ranges that only failed later inside FFmpeg. It now checks every duration and raises ValueError naming the offending index before any range is built.

  • Zero and None still yield an empty (t, t) range that keeps the part's slot, so later indices stay aligned. Empty input still returns [].
  • A non-numeric value raises ValueError with the index instead of a bare conversion error.
  • The contract is written in the docstring and the README.

Plan unit: KC-1 (portfolio remediation 2026-09-29).

Test plan

  • New TestDurationValidation in tests/test_segments.py: [10, -5, 3], NaN, +inf, -inf, a non-numeric string, generator input, and monotonic output for supported input. Six of these were red before the change (DID NOT RAISE ValueError).
  • Full suite locally: 142 passed. ruff check . clean.

Acceptance

  • Ranges are monotonic for supported input: test_supported_input_gives_monotonic_ranges.
  • [10, -5, 3], NaN and infinity fail before FFmpeg: the error is raised inside boundaries_from_durations.
  • Zero and empty input follow a documented contract: docstring, README, existing tests unchanged.

Not in this PR

  • The consumer pin in the video service still points at v0.1.0. It needs a new tag first.

@joepetjr
joepetjr merged commit 30040db into main Oct 1, 2026
4 checks passed
@joepetjr
joepetjr deleted the fix/kc-1-validate-durations branch October 1, 2026 22:40
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