fix(files): remove io.Seeker from File interface#1128
Open
Conversation
Not all File implementations can seek. ReaderFile wrapping an HTTP multipart stream and WebFile both returned ErrNotSupported at runtime, which caused interface-sniffing bugs in downstream consumers like go-car (ipfs/kubo#9361). Seeking is now opt-in: implementations that support it (ReaderFile with a seekable reader, Symlink, ufsFile) still have a Seek method and callers type-assert to io.Seeker when needed. - files: remove io.Seeker from File interface - files: remove dummy WebFile.Seek that always returned ErrNotSupported - gateway: type-assert to io.Seeker before seeking in all handlers
Codecov Report❌ Patch coverage is @@ Coverage Diff @@
## main #1128 +/- ##
==========================================
- Coverage 62.56% 62.52% -0.04%
==========================================
Files 261 261
Lines 26216 26235 +19
==========================================
+ Hits 16402 16404 +2
- Misses 8125 8140 +15
- Partials 1689 1691 +2
... and 7 files with indirect coverage changes 🚀 New features to boost your workflow:
|
lidel
added a commit
to ipfs/kubo
that referenced
this pull request
Mar 26, 2026
Update boxo to ipfs/boxo#1128 which removes io.Seeker from the files.File interface. Callers that need seeking now type-assert to io.Seeker. - core/commands/cat: type-assert before seeking - core/coreiface/tests: type-assert before seeking
3 tasks
3 tasks
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.
Warning
dont merge, this is for illustrative purpose only
Not all File implementations can seek.
ReaderFilewrapping an HTTP multipart stream andWebFileboth returnedErrNotSupportedat runtime, which caused interface-sniffing bugs in downstream consumers like go-car (ipfs/kubo#9361).Not sure if this PR (removal of io.Seeker from File interface) is the "lesser evil", opening this mostly to have PR with code example.
With this PR seeking is now opt-in: implementations that support it (ReaderFile with a seekable reader, Symlink, ufsFile) still have a Seek method and callers type-assert to io.Seeker when needed.
files: removeio.SeekerfromFileinterfacefiles: remove dummyWebFile.Seekthat always returnedErrNotSupportedgateway: type-assert toio.Seekerbefore seeking in all handlersTest plan