{"record":{"id":"b5d9836543a76578","repo":"ipfs/kubo","slug":"error-loading-filesroot-from-dagservice-s","errorCode":null,"errorMessage":"error loading filesroot from dagservice: %s","messagePattern":"error loading filesroot from dagservice: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/node/core.go","lineNumber":243,"sourceCode":"\t\tval, err := repo.Datastore().Get(ctx, FilesRootDatastoreKey)\n\n\t\tswitch {\n\t\tcase errors.Is(err, datastore.ErrNotFound):\n\t\t\tnd = unixfs.EmptyDirNode()\n\t\t\terr := dag.Add(ctx, nd)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failure writing filesroot to dagstore: %s\", err)\n\t\t\t}\n\t\tcase err == nil:\n\t\t\tc, err := cid.Cast(val)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tofflineDag := merkledag.NewDAGService(blockservice.New(bs, offline.Exchange(bs)))\n\t\t\trnd, err := offlineDag.Get(ctx, c)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error loading filesroot from dagservice: %s\", err)\n\t\t\t}\n\n\t\t\tpbnd, ok := rnd.(*merkledag.ProtoNode)\n\t\t\tif !ok {\n\t\t\t\treturn nil, merkledag.ErrNotProtobuf\n\t\t\t}\n\n\t\t\tnd = pbnd\n\t\tdefault:\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// MFS (Mutable File System) provider integration: Only pass the provider\n\t\t// to MFS when the strategy includes \"mfs\". MFS will call StartProviding()\n\t\t// on every DAGService.Add() operation, which is sufficient for the \"mfs\"\n\t\t// strategy - it ensures all MFS content gets announced as it's added or\n\t\t// modified. For non-mfs strategies, we set provider to nil to avoid\n\t\t// unnecessary providing.","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/node/core.go#L225-L261","documentation":"When a stored filesroot CID exists, Kubo loads the MFS root using an offline (local-only, no-network) DAGService built around the blockstore. If `offlineDag.Get(ctx, c)` fails — typically ipld.ErrNotFound when the root block is missing locally — the error is wrapped as \"error loading filesroot from dagservice\". Deliberately offline: a network fetch would be unsafe/slow during startup.","triggerScenarios":"Daemon startup with a filesroot CID recorded in the datastore whose root block was removed by `ipfs repo gc` (or never fetched, or the repo was copied/truncated), so the offline blockstore lookup returns not-found; also any blockstore read error, and CID type mismatch paths nearby.","commonSituations":"Running `ipfs repo gc` that collected unpinned MFS blocks due to the known GC-vs-MFS wedge on older versions; manually deleting blocks from the blockstore; restoring $IPFS_PATH/datastore from a partial backup; copying a repo between machines without all blocks.","solutions":["Recover the missing blocks: if you know the MFS root CID, fetch it from the network (`ipfs get <cid>`) on another instance or from a pinning backup, then re-add and `ipfs files cp /ipfs/<cid> /`.","If the MFS tree is unrecoverable, reset it: remove the FilesRoot key so a fresh empty root is created (back up the repo first).","Upgrade Kubo — recent versions fix the GC-vs-MFS wedge (ipfs/kubo#10842) so live MFS blocks are never collected.","Before GC, keep MFS root pinned or run GC with care; check what was collected with `ipfs repo gc --stream-errors`."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# Check that the MFS root block exists locally before stopping the daemon\nROOT=$(ipfs files stat / --hash)\nipfs cat \"$ROOT\" > /dev/null && echo \"root present\" || echo \"WARNING: root block missing; do not run repo gc\"","typeGuard":null,"tryCatchPattern":"// Detect the missing-block case explicitly\nrnd, err := offlineDag.Get(ctx, c)\nif err != nil {\n    if errors.Is(err, ipld.ErrNotFound) {\n        // MFS root block was GC'd or lost: restore from backup or reset MFS\n        return fmt.Errorf(\"MFS root %s missing from local blockstore: %w\", c, err)\n    }\n    return fmt.Errorf(\"error loading filesroot from dagservice: %w\", err)\n}","preventionTips":["Pin the MFS root or use the `mfs` Provide strategy so GC never collects live MFS blocks.","Upgrade to a Kubo version with the GC-vs-MFS wedge fix (ipfs/kubo#10842).","Back up IPFS_PATH (or pin critical MFS content) before running `ipfs repo gc`.","Never manually delete blocks from the blockstore directory."],"tags":["mfs","blockstore","garbage-collection","startup"],"backgroundTag":"block-not-found-locally","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}