Skip to content

fix(files): remove io.Seeker from File interface#1128

Open
lidel wants to merge 2 commits intomainfrom
fix/files-remove-seeker-from-file-interface
Open

fix(files): remove io.Seeker from File interface#1128
lidel wants to merge 2 commits intomainfrom
fix/files-remove-seeker-from-file-interface

Conversation

@lidel
Copy link
Member

@lidel lidel commented Mar 26, 2026

Warning

dont merge, this is for illustrative purpose only

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).

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: 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

Test plan

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
Copy link

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 20.00000% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.52%. Comparing base (43c30ce) to head (003799d).

Files with missing lines Patch % Lines
gateway/backend_blocks.go 14.28% 9 Missing and 3 partials ⚠️
gateway/backend_car.go 0.00% 4 Missing ⚠️
gateway/handler_block.go 20.00% 2 Missing and 2 partials ⚠️
gateway/handler_codec.go 40.00% 2 Missing and 1 partial ⚠️
gateway/backend_car_files.go 50.00% 1 Missing ⚠️

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
files/webfile.go 73.91% <ø> (+3.07%) ⬆️
gateway/backend_car_files.go 57.93% <50.00%> (ø)
gateway/handler_codec.go 61.44% <40.00%> (-0.90%) ⬇️
gateway/backend_car.go 49.78% <0.00%> (-0.22%) ⬇️
gateway/handler_block.go 59.37% <20.00%> (-4.92%) ⬇️
gateway/backend_blocks.go 44.42% <14.28%> (-0.50%) ⬇️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
@lidel lidel marked this pull request as ready for review March 26, 2026 20:23
@lidel lidel requested a review from a team as a code owner March 26, 2026 20:23
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