{"record":{"id":"83cd5bcfcd4aea2d","repo":"ipfs/kubo","slug":"reading-current-mfs-root-w","errorCode":null,"errorMessage":"reading current MFS root: %w","messagePattern":"reading current MFS root: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1808,"sourceCode":"\t\t\tfsNode, err := ft.FSNodeFromBytes(pbNode.Data())\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"new root is not a valid UnixFS node: %w\", err)\n\t\t\t}\n\t\t\tif fsNode.Type() != ft.TDirectory && fsNode.Type() != ft.THAMTShard {\n\t\t\t\treturn fmt.Errorf(\"new root must be a directory, got %s\", fsNode.Type())\n\t\t\t}\n\t\t}\n\n\t\t// Get old root for display (if exists)\n\t\tvar oldRootStr string\n\t\toldRootBytes, err := localDS.Get(req.Context, node.FilesRootDatastoreKey)\n\t\tif err == nil {\n\t\t\toldRootCid, err := cid.Cast(oldRootBytes)\n\t\t\tif err == nil {\n\t\t\t\toldRootStr = enc.Encode(oldRootCid)\n\t\t\t}\n\t\t} else if !errors.Is(err, datastore.ErrNotFound) {\n\t\t\treturn fmt.Errorf(\"reading current MFS root: %w\", err)\n\t\t}\n\n\t\t// Write new root\n\t\terr = localDS.Put(req.Context, node.FilesRootDatastoreKey, newRootCid.Bytes())\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"writing new MFS root: %w\", err)\n\t\t}\n\n\t\t// Build output message\n\t\tnewRootStr := enc.Encode(newRootCid)\n\t\tvar msg string\n\t\tif oldRootStr != \"\" {\n\t\t\tmsg = fmt.Sprintf(\"MFS root changed from %s to %s\\n\", oldRootStr, newRootStr)\n\t\t\tmsg += fmt.Sprintf(\"The old root %s will be garbage collected unless pinned.\\n\", oldRootStr)\n\t\t} else {\n\t\t\tmsg = fmt.Sprintf(\"MFS root set to %s\\n\", newRootStr)\n\t\t}\n","sourceCodeStart":1790,"sourceCodeEnd":1826,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1790-L1826","documentation":"While collecting the old root CID for display, the local datastore Get for the MFS root key failed with an error other than datastore.ErrNotFound (which is treated as 'no previous root'). This is an unexpected datastore read failure (I/O, corruption) and aborts the root replacement before the new root is written.","triggerScenarios":"Thrown at core/commands/files.go:1808 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped inner error for datastore/disk issues and verify disk health and free space under IPFS_PATH.","After fixing the underlying datastore problem, retry the root replacement; nothing was written when this error fired."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}