{"record":{"id":"cd45b52377416ce8","repo":"ipfs/kubo","slug":"writing-new-mfs-root-w","errorCode":null,"errorMessage":"writing new MFS root: %w","messagePattern":"writing new MFS root: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1814,"sourceCode":"\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\n\t\treturn cmds.EmitOnce(res, &MessageOutput{Message: msg})\n\t},\n\tType: MessageOutput{},\n\tEncoders: cmds.EncoderMap{\n\t\tcmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, out *MessageOutput) error {\n\t\t\t_, err := fmt.Fprint(w, out.Message)","sourceCodeStart":1796,"sourceCodeEnd":1832,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1796-L1832","documentation":"The validated new root CID could not be persisted: localDS.Put of the MFS root datastore key failed (disk full, I/O error, datastore failure). All validation already passed; the failure is at the final write, so the MFS root remains unchanged unless the datastore partially persisted the put.","triggerScenarios":"Thrown at core/commands/files.go:1814 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check free disk space and datastore health under IPFS_PATH, fix the wrapped cause, then retry the root replacement.","Verify the current root with `ipfs files stat /` after recovery to confirm which root is active."],"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"}