Open
Conversation
Regression test for #9361. Imports a CARv2 fixture via the daemon (online mode) and verifies the blocks are accessible. Currently fails with "operation not supported" due to the multipart reader not supporting seeking.
Strip the io.Seeker interface from the file before passing it to go-car's NewBlockReader. Over the HTTP API the underlying reader is a multipart stream that cannot seek, but boxo's ReaderFile advertises io.Seeker and returns ErrNotSupported at runtime. Hiding the interface lets go-car fall back to forward-only reading. Fixes #9361
This was referenced Mar 26, 2026
Open
|
@filebase Could you integrate this fix into your backend, please? Thanks in advance! |
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
ipfs dag importfails withError: operation not supportedwhen importing CARv2 files with the daemon running (i.e., over the HTTP API). CARv1 works fine, and CARv2 also works in offline mode.The root cause is an interface sniffing mismatch between three layers:
Fileinterface was grandfathered from old https://github.com/ipfs/go-ipfs-files. It requiresio.Seeker, soReaderFileimplementsSeek()BUT returnsErrNotSupportedat runtime when the underlying reader (HTTP multipart stream) can't actually seekNewBlockReaderchecksr.(io.ReadSeeker)to decide how to skip to the CARv2 data payload: the type assertion succeeds becauseReaderFilehas aSeekmethod, so it tries to seekThe irony is that go-car already has a fallback for non-seekable readers (
discardingReadSeekerPlusByte) that handles forward-only seeking by reading and discarding bytes. It just never gets reached becauseReaderFilefalsely advertises seek support.The fix wraps the file in a plain
io.Reader+io.Closerbefore passing it toNewBlockReader, stripping theio.Seekerinterface so go-car uses its forward-only fallback.Test plan
TestDagImportCARv2that imports a CARv2 fixture via the daemon (online) and verifies blocks are accessibleError: operation not supported), passes with itTestDagtests still passReferences
files.Filetype as a separate PR, see fix(files): remove io.Seeker from File interface boxo#1128, but this PR can be merged independently to fix the CARv2 support)