Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unknown fetcher type error #8830

Merged
merged 2 commits into from
Apr 6, 2022
Merged

fix: unknown fetcher type error #8830

merged 2 commits into from
Apr 6, 2022

Conversation

lidel
Copy link
Member

@lidel lidel commented Mar 28, 2022

Closes #8780

@lidel lidel added this to the go-ipfs 0.13 milestone Mar 28, 2022
@lidel lidel requested a review from gammazero March 28, 2022 20:12
Comment on lines 34 to 36
case nil:
// https://github.com/ipfs/go-ipfs/issues/8780
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we end up with one of these?

Copy link
Member Author

Choose a reason for hiding this comment

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

We probably don't – opened this draft PR to run CI and then look closer.

I now suspect we don't have nil here, but a RetryFetcher which wraps NewHttpFetcher:
https://github.com/ipfs/go-ipfs/blob/a6d04184062d1883f090d9661a4d8170a726cfc4/repo/fsrepo/migrations/migrations.go#L165

iiuc switch over fetcher type interprets RetryFetcher as something other than IpfsFetcher and HttpFetcher and that is why default gets executed.

Quick demo: https://go.dev/play/p/MEKo40x1z0I

Copy link
Member Author

@lidel lidel Mar 28, 2022

Choose a reason for hiding this comment

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

@aschmahmann if we added RetryFetcher some time later, that probably introduced the bug.

Since it is only used for HTTP, we could fix it this way (https://go.dev/play/p/CTeMTLaEvN6):

- case *migrations.HttpFetcher:
+ case *migrations.HttpFetcher, *migrations.RetryFetcher:

I did that in be916e7 – thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add something to the Fetcher interface for this so we can remove this brittle type switch altogether?

Copy link
Member Author

@lidel lidel Apr 6, 2022

Choose a reason for hiding this comment

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

Probably, but at the same time we won't be adding any new Fetcher types any time soon.

I'm merging this one-liner fix for now – fwiw we will be revisiting fetchers after we have car export on gateways, to fetch CAR instead of trusting ipfs.io to return right data, we can improve things as part of that work – filled #8851 for tracking that.

@lidel lidel marked this pull request as ready for review March 28, 2022 22:09
@lidel lidel requested a review from aschmahmann March 28, 2022 22:09
@lidel lidel merged commit e309682 into master Apr 6, 2022
@lidel lidel deleted the fix/error-on-nil-fetcher branch April 6, 2022 00:10
Copy link

@Joelsamijon Joelsamijon left a comment

Choose a reason for hiding this comment

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

cmd/ipfs/add_migrations.go

Comment on lines 37 to 38
if err != nil {
return err

Choose a reason for hiding this comment

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

gh pr checkout 8830

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Could not add migration to IPFS: Cannot get migrations from unknown fetcher type
4 participants