{"record":{"id":"26dc865f9a4de8c9","repo":"ipfs/kubo","slug":"can-only-update-directories","errorCode":null,"errorMessage":"can only update directories","messagePattern":"can only update directories","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1361,"sourceCode":"\t\treturn nil\n\t},\n}\n\nfunc updatePath(rt *mfs.Root, pth string, builder cid.Builder) error {\n\tif builder == nil {\n\t\treturn nil\n\t}\n\n\tnd, err := mfs.Lookup(rt, pth)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tswitch n := nd.(type) {\n\tcase *mfs.Directory:\n\t\tn.SetCidBuilder(builder)\n\tdefault:\n\t\treturn fmt.Errorf(\"can only update directories\")\n\t}\n\n\treturn nil\n}\n\nvar filesRmCmd = &cmds.Command{\n\tHelptext: cmds.HelpText{\n\t\tTagline: \"Remove a file from MFS.\",\n\t\tShortDescription: `\nRemove files or directories.\n\n    $ ipfs files rm /foo\n    $ ipfs files ls /bar\n    cat\n    dog\n    fish\n    $ ipfs files rm -r /bar\n`,","sourceCodeStart":1343,"sourceCodeEnd":1379,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1343-L1379","documentation":"Helper updatePath, used by `ipfs files chcid` to apply a new CID builder: after mfs.Lookup resolves the path, the type switch finds the node is not an *mfs.Directory (a regular file or symlink), so SetCidBuilder cannot be applied. Fires when a user points chcid at a file rather than a directory.","triggerScenarios":"Thrown at core/commands/files.go:1361 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run `ipfs files chcid` on a directory path only; check the target with `ipfs files stat` first.","If the whole tree should change CID format, apply chcid to the parent directory (it propagates on rebuild) rather than to individual files."],"exampleFix":null,"handlingStrategy":"validation","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"}