{"record":{"id":"a1b61bf448518e1a","repo":"ipfs/kubo","slug":"unrecognized-multihash-function-s","errorCode":null,"errorMessage":"unrecognized multihash function: %s","messagePattern":"unrecognized multihash function: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/block.go","lineNumber":201,"sourceCode":"\n\t\tnd, err := cmdenv.GetNode(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcfg, err := nd.Repo.Config()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tmhtype, _ := req.Options[mhtypeOptionName].(string)\n\t\tif mhtype == \"\" {\n\t\t\tmhtype = cfg.Import.HashFunction.WithDefault(config.DefaultHashFunction)\n\t\t}\n\n\t\tmhtval, ok := mh.Names[mhtype]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unrecognized multihash function: %s\", mhtype)\n\t\t}\n\n\t\tmhlen, ok := req.Options[mhlenOptionName].(int)\n\t\tif !ok {\n\t\t\treturn errors.New(\"missing option \\\"mhlen\\\"\")\n\t\t}\n\n\t\tcidCodec, _ := req.Options[blockCidCodecOptionName].(string)\n\t\tformat, _ := req.Options[blockFormatOptionName].(string) // deprecated\n\n\t\t// use of legacy 'format' needs to suppress 'cid-codec'\n\t\tif format != \"\" {\n\t\t\tif cidCodec != \"\" && cidCodec != \"raw\" {\n\t\t\t\treturn fmt.Errorf(\"unable to use %q (deprecated) and a custom %q at the same time\", blockFormatOptionName, blockCidCodecOptionName)\n\t\t\t}\n\t\t\tcidCodec = \"\" // makes it no-op\n\t\t}\n","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/block.go#L183-L219","documentation":"`ipfs block put --mhtype <name>` (or Import.HashFunction config) must name a multihash function present in the mh.Names registry. The given string is not a known multihash name, so hashing cannot proceed. Default comes from cfg.Import.HashFunction when the option is empty.","triggerScenarios":"Run `ipfs block put --mhtype sha3512` (typo); --mhtype with a codec name instead of a hash name; mh.Names[mhtype] lookup fails for any misspelled or unsupported hash function.","commonSituations":"Typos in multihash names; users assuming any multicodec name is valid (e.g. passing 'blake3' variants not compiled in); scripts copying flags between commands where the option means something else.","solutions":["Use a valid multihash name, e.g. --mhtype sha2-256 or --mhtype sha2-512","List valid choices from the multihash registry (sha2-256, sha2-512, sha3-512, blake2b-256, identity, etc.)","Check the Import.HashFunction config value if no --mhtype was passed: ipfs config Import.HashFunction"],"exampleFix":"// before\nipfs block put --mhtype sha256 data.bin\n// after\nipfs block put --mhtype sha2-256 data.bin","handlingStrategy":"validation","validationCode":"// shell: whitelist allowed hash names before passing --mhtype\ncase \"$MH\" in\n  sha2-256|sha2-512|sha3-512|blake2b-256|blake2b-512|identity) ;;\n  *) echo \"unsupported mhtype: $MH\" >&2; exit 1 ;;\nesac\nipfs block put --mhtype \"$MH\" data.bin","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use canonical multihash names (sha2-256, not sha256)","Check `ipfs config Import.HashFunction` when the error appears without --mhtype","Keep a constant list of supported hashes in wrapper scripts"],"tags":["cli","multihash","block-put","bad-flag-value"],"backgroundTag":"invalid-multihash-name","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"}