{"record":{"id":"a7f936b72b27f42b","repo":"ipfs/kubo","slug":"import-unixfshamtdirectorysizeestimation-must-be","errorCode":null,"errorMessage":"Import.UnixFSHAMTDirectorySizeEstimation must be %q, %q, or %q, got %q","messagePattern":"Import\\.UnixFSHAMTDirectorySizeEstimation must be %q, %q, or %q, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/import.go","lineNumber":160,"sourceCode":"\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}\n\n\t// Validate UnixFSDAGLayout\n\tif !cfg.UnixFSDAGLayout.IsDefault() {\n\t\tlayout := cfg.UnixFSDAGLayout.WithDefault(DefaultUnixFSDAGLayout)\n\t\tswitch layout {\n\t\tcase DAGLayoutBalanced, DAGLayoutTrickle:\n\t\t\t// valid\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"Import.UnixFSDAGLayout must be %q or %q, got %q\",\n\t\t\t\tDAGLayoutBalanced, DAGLayoutTrickle, layout)\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/import.go#L142-L178","documentation":"Import.UnixFSHAMTDirectorySizeEstimation controls how HAMT directory shard sizes are estimated when importing ('links', 'block', or 'disabled'). ValidateImportConfig uses an exhaustive switch and rejects any other string, so a misspelled or foreign value fails config validation at startup.","triggerScenarios":"Setting Import.UnixFSHAMTDirectorySizeEstimation to anything other than the exact strings 'links', 'block', or 'disabled' (case-sensitive) — e.g. 'true', 'none', 'Links', 'off' — then starting the daemon or running ValidateImportConfig.","commonSituations":"Typo or wrong casing when hand-editing the config; guessing value names from documentation of a different option; scripting config writes with unvalidated user input.","solutions":["Set the value to one of exactly 'links', 'block', or 'disabled': ipfs config Import.UnixFSHAMTDirectorySizeEstimation links","Remove the setting to use the default 'links': ipfs config --json Import.UnixFSHAMTDirectorySizeEstimation null","If the intent was to disable HAMT sharding entirely, use 'disabled' (not 'none' or 'off')"],"exampleFix":"// before\nipfs config Import.UnixFSHAMTDirectorySizeEstimation none\n// after\nipfs config Import.UnixFSHAMTDirectorySizeEstimation disabled","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"links\": true, \"block\": true, \"disabled\": true}\nif v := est.WithDefault(\"links\"); !valid[v] {\n\treturn fmt.Errorf(\"UnixFSHAMTDirectorySizeEstimation must be links|block|disabled\")\n}","typeGuard":"func isHAMTSizeEstimation(s string) bool {\n\tswitch s {\n\tcase \"links\", \"block\", \"disabled\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":null,"preventionTips":["Use the exported constants HAMTSizeEstimationLinks/Block/Disabled in Go code instead of raw strings","Values are lowercase and case-sensitive; never capitalize","To disable HAMT sharding use 'disabled', not 'none' or 'off'"],"tags":["config","hamt","unixfs","validation"],"backgroundTag":"invalid-enum-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"}