fix: allow custom http provide when libp2p node is offline#10974
Merged
fix: allow custom http provide when libp2p node is offline#10974
Conversation
3 tasks
16ad7c9 to
d7fa9b0
Compare
Routing.Type=custom is a niche power user feature without a spec, so we don't want to bring attention to it in the changelog. The functionality remains available for those who need it.
guillaumemichel
commented
Sep 19, 2025
- fixed comment/function name mismatch - added mock server test for HTTP provide success - clarified test names for offline scenarios
28157bc to
6fdf929
Compare
use h.NewNode().Init() instead of NewNodes(1) for cleaner test setup
when no DHT is available but HTTP routers are configured for providing, return NoopProvider instead of failing. this allows the daemon to start and HTTP-based providing to work through the routing system. moved HTTP provider detection to config package as HasHTTPProviderConfigured() for better code organization and reusability. this fix is important as SweepingProvider will become the new default in the future.
lidel
reviewed
Sep 19, 2025
Comment on lines
+356
to
+361
| // No DHT available, check if HTTP provider is configured | ||
| cfg, err := in.Repo.Config() | ||
| if err == nil && cfg.HasHTTPProviderConfigured() { | ||
| // HTTP provider is configured, return NoopProvider to allow HTTP-based providing | ||
| return &NoopProvider{}, keyStore, nil | ||
| } |
Member
There was a problem hiding this comment.
Ok, tests failed because SweepingProvider failed to initialize when there's no DHT available, even when HTTP routers were configured for providing.
I've applied more surgical fix for now, will evaluate #10975 later.
lidel
approved these changes
Sep 19, 2025
Member
lidel
left a comment
There was a problem hiding this comment.
Did some refactoring, hopefully not breaking anything.
We will ask Plebbit to test once 0.38.0-rc1 is tagged so low risk to merge.
lidel
added a commit
that referenced
this pull request
Sep 19, 2025
when SweepingProvider is enabled but no DHT is available (e.g., Routing.Type=none), the daemon would panic with a nil pointer dereference in ResettableKeystore.ResetCids. this fix: - returns NoopProvider when no DHT implementation is available - skips keystore initialization for NoopProvider to avoid unnecessary operations - allows nodes to run without DHT when using HTTP-only routing or offline mode the panic occurred because initKeyStore tried to access a nil keystore when SweepingProvider returned nil for the keystore parameter. by checking if the provider is NoopProvider and skipping keystore operations, we avoid the panic while maintaining correct behavior for all other provider types. cc #10974 #10975
lidel
added a commit
that referenced
this pull request
Sep 19, 2025
* fix: SweepingProvider shouldn't error when missing DHT * fix: prevent panic when SweepingProvider has no DHT when SweepingProvider is enabled but no DHT is available (e.g., Routing.Type=none), the daemon would panic with a nil pointer dereference in ResettableKeystore.ResetCids. this fix: - returns NoopProvider when no DHT implementation is available - skips keystore initialization for NoopProvider to avoid unnecessary operations - allows nodes to run without DHT when using HTTP-only routing or offline mode the panic occurred because initKeyStore tried to access a nil keystore when SweepingProvider returned nil for the keystore parameter. by checking if the provider is NoopProvider and skipping keystore operations, we avoid the panic while maintaining correct behavior for all other provider types. cc #10974 #10975 --------- Co-authored-by: Marcin Rataj <lidel@lidel.org>
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.
Fixes #10967
Current state
ipfs routing provide <cid>fails if kubo isn't connected to any other peer (libp2p). It doesn't even attempt to provide.Problem
When
customRouting is used, it is acceptable to provide to a custom HTTP router (instead of a DHT over libp2p). If the node is configured to provide to a HTTP router,ipfs routing provide <cid>still fails if kubo isn't connected to other libp2p nodes. Such connections aren't necessary to provide to an HTTP endpoint.Fix
Return the error
cannot provide, no connected peers, only if no custom HTTP providers are configured AND kubo has no libp2p connections.