{"record":{"id":"ae8647565e198152","repo":"ipfs/kubo","slug":"unrecognized-hash-function-q-ae8647","errorCode":null,"errorMessage":"unrecognized hash function: %q","messagePattern":"unrecognized hash function: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1502,"sourceCode":"// getPrefix builds a cid.Builder from CLI flags, falling back to importCfg\n// when provided. Returns (nil, nil) when neither CLI nor config set a value.\nfunc getPrefix(req *cmds.Request, importCfg *config.Import) (cid.Builder, error) {\n\tcidVer, cidVerSet := req.Options[filesCidVersionOptionName].(int)\n\thashFunStr, hashFunSet := req.Options[filesHashOptionName].(string)\n\n\tif cidVerSet || hashFunSet {\n\t\t// CLI flags take precedence: build prefix from them directly.\n\t\tif hashFunSet && cidVer == 0 {\n\t\t\tcidVer = 1\n\t\t}\n\t\tprefix, err := dag.PrefixForCidVersion(cidVer)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif hashFunSet {\n\t\t\thashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)]\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"unrecognized hash function: %q\", hashFunStr)\n\t\t\t}\n\t\t\tprefix.MhType = hashFunCode\n\t\t\tprefix.MhLength = -1\n\t\t}\n\t\treturn &prefix, nil\n\t}\n\n\t// No CLI flags: fall back to Import config.\n\tif importCfg != nil {\n\t\treturn importCfg.UnixFSCidBuilder()\n\t}\n\n\treturn nil, nil\n}\n\nfunc ensureContainingDirectoryExists(r *mfs.Root, path string, opts ...mfs.Option) error {\n\tdirtomake := gopath.Dir(path)\n","sourceCodeStart":1484,"sourceCodeEnd":1520,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1484-L1520","documentation":"In getPrefix (used by `ipfs files chcid` and related MFS commands), the --hash option string could not be resolved to a known multihash function name when building the cid.Builder. It is a generic option-parsing guard; the unrecognized hash name is quoted in the message, and the command aborts before any node is modified.","triggerScenarios":"Thrown at core/commands/files.go:1502 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a supported multihash name, e.g. --hash sha2-256 or sha2-512.","List valid names via the multihash codec registry and re-run the command with a corrected --hash value."],"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"}