Reject out-of-range negative sampling starts - #1669
Closed
aswanth-07 wants to merge 1 commit into
Closed
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1669
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
aswanth-07
marked this pull request as ready for review
August 23, 2026 11:45
Author
|
Closing this PR after audit. It adds a guard for an out-of-range sampling input without a user-reported issue or maintainer-confirmed contract. This needs an issue-first scope decision before a direct contribution. The source branch remains available. |
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
Validate the lower bound of sampling_range_start before normalizing negative indices.
Root cause
Values below -len(decoder) were normalized to a still-negative frame index and could reach the index-based sampler/decoder path instead of being rejected as invalid input. The fix rejects those values while preserving the valid boundary at -len(decoder).
Verification
Additional context
No open issue or pull request was found for this exact lower-bound case at the time of preparation. The validation follows the existing Python-style negative-index boundary: -len(decoder) is valid and smaller values are rejected before normalization.
AI assistance was used to prepare this draft. The submitter is responsible for reviewing, understanding, and defending every changed line. No CLA or other legal agreement has been accepted on the submitter's behalf.