ipfs/kubo · error

provider: error loading MFS root, cannot provide MFS: %w

Error message

provider: error loading MFS root, cannot provide MFS: %w

What it means

This error is returned by the MFS-based provider KeyChanFunc (mfsProvider) in kubo's provider wiring. During a reprovide cycle, after FlushMemFree succeeds, it fetches the MFS root directory's underlying IPLD node via mfsRoot.GetDirectory().GetNode(); if that fails (the root node cannot be loaded from the blockstore or the MFS tree is inconsistent), the provider aborts and the MFS contents are not announced to the routing system. The wrapped underlying error identifies the actual datastore/blockstore failure.

Source

Thrown at core/node/provider.go:1209

	return fx.Options(opts...)
}

// OfflineProviders groups units managing provide routing records offline
func OfflineProviders() fx.Option {
	return fx.Provide(func() DHTProvider {
		return &NoopProvider{}
	})
}

func mfsProvider(mfsRoot *mfs.Root, fetcher fetcher.Factory) provider.KeyChanFunc {
	return func(ctx context.Context) (<-chan cid.Cid, error) {
		err := mfsRoot.FlushMemFree(ctx)
		if err != nil {
			return nil, fmt.Errorf("provider: error flushing MFS, cannot provide MFS: %w", err)
		}
		rootNode, err := mfsRoot.GetDirectory().GetNode()
		if err != nil {
			return nil, fmt.Errorf("provider: error loading MFS root, cannot provide MFS: %w", err)
		}

		kcf := provider.NewDAGProvider(rootNode.Cid(), fetcher)
		return kcf(ctx)
	}
}

type provStrategyIn struct {
	fx.In
	Pinner               pin.Pinner
	Blockstore           blockstore.Blockstore
	OfflineIPLDFetcher   fetcher.Factory `name:"offlineIpldFetcher"`
	OfflineUnixFSFetcher fetcher.Factory `name:"offlineUnixfsFetcher"`
	MFSRoot              *mfs.Root
	Repo                 repo.Repo
}

type provStrategyOut struct {

View on GitHub (pinned to 329838acdf)

Solutions

  1. Inspect the wrapped %w error in daemon logs to identify the underlying blockstore/datastore failure
  2. Run 'ipfs repo fsck' / verify repo integrity and check disk health
  3. Restart the daemon so the MFS root is re-initialized; the next reprovide retries automatically
  4. If the datastore is corrupt, restore from backup or re-add critical content and re-pin
Defensive patterns

Strategy: retry

Validate before calling

// before relying on reprovide, verify MFS root is loadable:
node, err := mfsRoot.GetDirectory().GetNode()
if err != nil {
    log.Fatalf("MFS root unavailable, reprovide of MFS will fail: %v", err)
}

Type guard

if mfsRoot == nil || mfsRoot.GetDirectory() == nil {
    // MFS root not initialized; skip MFS providing
}

Try / catch

_, err := keyChanFunc(ctx)
if err != nil {
    var dsErr datastore.ErrNotFound
    if errors.As(err, &dsErr) {
        // MFS root block missing: repair repo before next cycle
    }
    log.Warnw("MFS reprovide skipped", "error", err)
}

Prevention

When it happens

Trigger: Reprovide cycle with Provide.Strategy including 'mfs' while the MFS root node cannot be materialized: blockstore read errors, corrupted MFS root entry, or mfs.Root not properly initialized when GetDirectory().GetNode() is called.

Common situations: Corrupted or truncated datastore after a crash, disk I/O errors, running with a repo whose MFS root was written by an incompatible version, or a bug in node construction leaving MFSRoot uninitialized.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/6ae1fde3e22bd42c. Report an issue: GitHub.