{"record":{"id":"02b25244ee9adffb","repo":"ipfs/kubo","slug":"import-unixfschunker-invalid-format-q-expected","errorCode":null,"errorMessage":"Import.UnixFSChunker invalid format: %q (expected \"size-<bytes>\", \"rabin-<min>-<avg>-<max>\", or \"buzhash\")","messagePattern":"Import\\.UnixFSChunker invalid format: %q \\(expected \"size-<bytes>\", \"rabin-<min>-<avg>-<max>\", or \"buzhash\"\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/import.go","lineNumber":136,"sourceCode":"\t\tmaxNodes := cfg.BatchMaxNodes.WithDefault(DefaultBatchMaxNodes)\n\t\tif maxNodes <= 0 {\n\t\t\treturn fmt.Errorf(\"Import.BatchMaxNodes must be positive, got %d\", maxNodes)\n\t\t}\n\t}\n\n\t// Validate BatchMaxSize\n\tif !cfg.BatchMaxSize.IsDefault() {\n\t\tmaxSize := cfg.BatchMaxSize.WithDefault(DefaultBatchMaxSize)\n\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() {","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/import.go#L118-L154","documentation":"ValidateImportConfig checks Import.UnixFSChunker against the supported chunker syntax: \"size-<bytes>\", \"rabin-<min>-<avg>-<max>\", or \"buzhash\". If the configured string does not match any accepted format (isValidChunker fails), import is rejected with this error naming the offending value.","triggerScenarios":"Setting Import.UnixFSChunker to a malformed string, e.g. \"size\" (missing -<bytes>), \"rabin-1024\" (missing min/avg/max), \"fixed-262144\", or an empty/unknown format, then starting the daemon or adding files.","commonSituations":"Porting `ipfs add --chunker` values into config with syntax mistakes; forgetting the rabin three-number format; whitespace or case typos in the chunker string.","solutions":["Rewrite the chunker in a valid format: \"size-262144\", \"rabin-262144-524288-1048576\", or \"buzhash\"","Remove Import.UnixFSChunker to use DefaultUnixFSChunker","Test the format with `ipfs add --chunker <value>` before writing it into the config"],"exampleFix":"// before\n{\"Import\": {\"UnixFSChunker\": \"size\"}}\n// after\n{\"Import\": {\"UnixFSChunker\": \"size-262144\"}}","handlingStrategy":"validation","validationCode":"var chunkerRe = regexp.MustCompile(`^(size-\\d+|rabin-\\d+-\\d+-\\d+|buzhash)$`)\nfunc validChunker(s string) bool { return chunkerRe.MatchString(s) }","typeGuard":null,"tryCatchPattern":"if err := config.ValidateImportConfig(&importCfg); err != nil {\n\tif strings.Contains(err.Error(), \"UnixFSChunker invalid format\") {\n\t\timportCfg.UnixFSChunker = config.DefaultUnixFSChunker\n\t\terr = config.ValidateImportConfig(&importCfg)\n\t}\n\treturn err\n}","preventionTips":["Stick to the exact syntaxes: size-<bytes>, rabin-<min>-<avg>-<max>, buzhash","Test the chunker string with `ipfs add --chunker <value>` before persisting it to config","Watch for rabin requiring all three numbers (min-avg-max)","Omit the key to use the default chunker and keep CIDs stable"],"tags":["config","chunker","validation","import"],"backgroundTag":"invalid-config-value","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"}