{"record":{"id":"2c472dc512872318","repo":"ipfs/kubo","slug":"import-unixfsdaglayout-must-be-q-or-q-got-q","errorCode":null,"errorMessage":"Import.UnixFSDAGLayout must be %q or %q, got %q","messagePattern":"Import\\.UnixFSDAGLayout must be %q or %q, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/import.go","lineNumber":172,"sourceCode":"\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}\n\n// isPowerOfTwo checks if a number is a power of 2\nfunc isPowerOfTwo(n int64) bool {\n\treturn n > 0 && (n&(n-1)) == 0\n}\n\n// isValidChunker validates chunker format\nfunc isValidChunker(chunker string) bool {\n\tif chunker == \"buzhash\" {\n\t\treturn true\n\t}\n","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/import.go#L154-L190","documentation":"Import.UnixFSDAGLayout selects the UnixFS DAG layout used when importing files: 'balanced' (default) or 'trickle'. ValidateImportConfig accepts only these two exact strings and returns this error for any other value, catching bad layouts before any data is imported.","triggerScenarios":"Setting Import.UnixFSDAGLayout to a string other than 'balanced' or 'trickle' — e.g. the old CLI flag value 'trickle-dag', 'default', or a capitalized 'Balanced' — then starting the daemon.","commonSituations":"Copy-pasting the legacy '--trickle' flag name into the config; assuming other layouts (e.g. 'flat') exist; hand-editing config.json with casing mistakes.","solutions":["Set the layout to exactly 'balanced' or 'trickle': ipfs config Import.UnixFSDAGLayout balanced","Remove the setting to use the default 'balanced': ipfs config --json Import.UnixFSDAGLayout null","Use the CLI flag '--trickle' per-invocation instead of a config value if trickle is only needed for one add"],"exampleFix":"// before\nipfs config Import.UnixFSDAGLayout trickle-dag\n// after\nipfs config Import.UnixFSDAGLayout trickle","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"balanced\": true, \"trickle\": true}\nif v := layout.WithDefault(\"balanced\"); !valid[v] {\n\treturn fmt.Errorf(\"UnixFSDAGLayout must be balanced|trickle\")\n}","typeGuard":"func isDAGLayout(s string) bool {\n\treturn s == \"balanced\" || s == \"trickle\"\n}","tryCatchPattern":null,"preventionTips":["Use constants config.DAGLayoutBalanced / config.DAGLayoutTrickle in Go code","The CLI '--trickle' flag maps to 'trickle'; never write 'trickle-dag' in config","Omit the key entirely to get the 'balanced' default"],"tags":["config","unixfs","dag-layout","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"}