{"record":{"id":"099a94646bc9d870","repo":"ipfs/kubo","slug":"import-hashfunction-unrecognized-q","errorCode":null,"errorMessage":"Import.HashFunction unrecognized: %q","messagePattern":"Import\\.HashFunction unrecognized: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/import.go","lineNumber":145,"sourceCode":"\t\tif maxSize <= 0 {\n\t\t\treturn fmt.Errorf(\"Import.BatchMaxSize must be positive, got %d\", maxSize)\n\t\t}\n\t}\n\n\t// Validate UnixFSChunker format\n\tif !cfg.UnixFSChunker.IsDefault() {\n\t\tchunker := cfg.UnixFSChunker.WithDefault(DefaultUnixFSChunker)\n\t\tif !isValidChunker(chunker) {\n\t\t\treturn fmt.Errorf(\"Import.UnixFSChunker invalid format: %q (expected \\\"size-<bytes>\\\", \\\"rabin-<min>-<avg>-<max>\\\", or \\\"buzhash\\\")\", chunker)\n\t\t}\n\t}\n\n\t// Validate HashFunction\n\tif !cfg.HashFunction.IsDefault() {\n\t\thashFunc := cfg.HashFunction.WithDefault(DefaultHashFunction)\n\t\thashCode, ok := mh.Names[strings.ToLower(hashFunc)]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"Import.HashFunction unrecognized: %q\", hashFunc)\n\t\t}\n\t\t// Check if the hash is allowed by verifcid\n\t\tif !verifcid.DefaultAllowlist.IsAllowed(hashCode) {\n\t\t\treturn fmt.Errorf(\"Import.HashFunction %q is not allowed for use in IPFS\", hashFunc)\n\t\t}\n\t}\n\n\t// Validate UnixFSHAMTDirectorySizeEstimation\n\tif !cfg.UnixFSHAMTDirectorySizeEstimation.IsDefault() {\n\t\test := cfg.UnixFSHAMTDirectorySizeEstimation.WithDefault(DefaultUnixFSHAMTDirectorySizeEstimation)\n\t\tswitch est {\n\t\tcase HAMTSizeEstimationLinks, HAMTSizeEstimationBlock, HAMTSizeEstimationDisabled:\n\t\t\t// valid\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"Import.UnixFSHAMTDirectorySizeEstimation must be %q, %q, or %q, got %q\",\n\t\t\t\tHAMTSizeEstimationLinks, HAMTSizeEstimationBlock, HAMTSizeEstimationDisabled, est)\n\t\t}\n\t}","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/import.go#L127-L163","documentation":"ValidateImportConfig rejects Import.HashFunction values that are not a known multihash name. The config string is lowercased and looked up in mh.Names (go-multihash); if no multihash code matches, startup/config-validation fails with this error. It exists so an invalid hash name is caught at daemon startup instead of at first 'ipfs add'.","triggerScenarios":"Setting Import.HashFunction in the kubo config (ipfs config Import.HashFunction <value>) to a string not in mh.Names — e.g. a typo ('sha256' without the dash, 'sha3-512x'), a made-up algorithm name, or extra whitespace — then starting the daemon or calling ValidateImportConfig.","commonSituations":"Typo in the hash name ('sha2-256' written as 'sha-256' or 'sha256'); copying a hash name from another tool with different naming; setting an algorithm that exists as a multihash but is so obscure it is fine here yet fails later at error 111 (this one is strictly 'unknown name').","solutions":["Check the exact multihash name against https://github.com/multiformats/go-multihash/blob/master/multihash.go (e.g. 'sha2-256', 'sha2-512', 'blake2b-256') and set it with: ipfs config Import.HashFunction sha2-256","Remove the setting to fall back to the default: ipfs config --json Import.HashFunction null (default is 'sha2-256')","Trim whitespace/case issues — the lookup lowercases the value, but embedded spaces or trailing newline (e.g. from shell substitution) will fail; set the value again carefully"],"exampleFix":"// before\nipfs config Import.HashFunction sha256\n// after\nipfs config Import.HashFunction sha2-256","handlingStrategy":"validation","validationCode":"func validHashFunc(name string) bool {\n\t_, ok := mh.Names[strings.ToLower(name)]\n\treturn ok\n}\nif !validHashFunc(cfg.Import.HashFunction.WithDefault(\"sha2-256\")) {\n\treturn fmt.Errorf(\"bad Import.HashFunction\")\n}","typeGuard":"func isKnownMultihash(name string) bool {\n\t_, ok := mh.Names[strings.ToLower(strings.TrimSpace(name))]\n\treturn ok\n}","tryCatchPattern":null,"preventionTips":["Use 'ipfs config' rather than editing config.json so values pass validation at write time","Copy hash names verbatim from the go-multihash table (sha2-256, sha2-512, blake2b-256)","Trim shell-substituted values to avoid stray whitespace/newlines"],"tags":["config","hash","validation","multihash"],"backgroundTag":"unknown-hash-function","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"}