Skip to content

fix(dataset): correct BlobFile seek semantics - #9358

Merged
wjones127 merged 1 commit into
lance-format:mainfrom
geruh:blob-neg-seek
Sep 18, 2026
Merged

wjones127 merged 1 commit into
lance-format:mainfrom
geruh:blob-neg-seek

Conversation

@geruh

@geruh geruh commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Followup to #9330.

Seeking before the start of a blob raised OverflowError when Python passed the negative position to Rust as a u64. This now raises ValueError and leaves the cursor unchanged.

Also fixes read() moving a cursor past EOF back to EOF. It now returns empty bytes and leaves the cursor where it was.

blob = dataset.take_blobs("images", indices=[0])[0]
blob.seek(-64, os.SEEK_END)
trailer = blob.read()

Testing

Added Python and Rust regression tests.

Python added a relative offset then passed it as u64. seek(-n, SEEK_CUR)
at 0 raised OverflowError. BytesIO raises ValueError. Zip and mp4 readers catch ValueError.

read() snapped a past-EOF cursor back to size. tell() stays where the
caller seeked.
@github-actions github-actions Bot added A-python Python bindings bug Something isn't working labels Sep 17, 2026
@geruh geruh changed the title fix(dataset): raise ValueError on negative BlobFile seek fix(dataset): correct BlobFile seek semantics Sep 17, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gate recommendation: approve.

This restores file-like cursor semantics at the correct boundaries: negative final seek positions are rejected before unsigned conversion without moving the cursor, while reads beyond EOF return empty bytes without moving the cursor backward. The regression coverage exercises all seek origins and both Python and Rust behavior.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 17, 2026
@wjones127
wjones127 merged commit aace517 into lance-format:main Sep 18, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-python Python bindings bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants