{"record":{"id":"aea2babf10f7b3cc","repo":"muesli/duf","slug":"unknown-theme-s","errorCode":null,"errorMessage":"unknown theme: %s","messagePattern":"unknown theme: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"themes.go","lineNumber":74,"sourceCode":"\t\tcolorBgYellow: env.Color(\"#fff4d0\"),\n\t\tcolorBgGreen:  env.Color(\"#e6ffe6\"),\n\t}\n\n\tthemes[\"ansi\"] = Theme{\n\t\tcolorRed:      env.Color(\"9\"),\n\t\tcolorYellow:   env.Color(\"11\"),\n\t\tcolorGreen:    env.Color(\"10\"),\n\t\tcolorBlue:     env.Color(\"12\"),\n\t\tcolorGray:     env.Color(\"7\"),\n\t\tcolorMagenta:  env.Color(\"13\"),\n\t\tcolorCyan:     env.Color(\"8\"),\n\t\tcolorBgRed:    env.Color(\"1\"),\n\t\tcolorBgYellow: env.Color(\"3\"),\n\t\tcolorBgGreen:  env.Color(\"2\"),\n\t}\n\n\tif _, ok := themes[theme]; !ok {\n\t\treturn Theme{}, fmt.Errorf(\"unknown theme: %s\", theme)\n\t}\n\n\treturn themes[theme], nil\n}\n","sourceCodeStart":56,"sourceCodeEnd":79,"githubUrl":"https://github.com/muesli/duf/blob/4636deb4a7b707a9f04c602db033f9837e50b3f6/themes.go#L56-L79","documentation":"loadTheme builds a fixed map of supported themes (\"dark\", \"light\", \"ansi\") and returns this error when the requested theme name is not a key in that map. It is a simple lookup failure: the theme string passed in (typically from a CLI flag or config) does not match any registered theme. The error message includes the offending theme name so the caller can see what was rejected.","triggerScenarios":"Calling loadTheme(name) where name is not exactly \"dark\", \"light\", or \"ansi\" — e.g. loadTheme(\"solarized\"), loadTheme(\"Dark\") (case mismatch), loadTheme(\"\"), or a misspelled name like \"dakr\". main reaches this whenever a user supplies an unlisted -theme/--theme flag value or a config file sets theme to an unknown name.","commonSituations":"A user passes --theme=monokai expecting extra built-in themes; a config file written for another tool carries a theme name this tool doesn't support; a typo or wrong casing (\"Dark\" vs \"dark\"); an empty theme value from an unset env var or blank CLI flag; version drift where a theme name was removed/renamed.","solutions":["Run with one of the supported theme names: dark, light, or ansi","Check the exact spelling and casing — the lookup is case-sensitive, so \"Dark\" fails","If the theme came from a config file or env var, fix or remove that value","List available themes from the tool's help output (or themes map in themes.go) and pick a valid one","If a new theme is genuinely needed, add it to the themes map in loadTheme (or contribute it upstream)"],"exampleFix":"// before\nloadTheme(\"Dark\") // -> unknown theme: Dark\n// after\nloadTheme(\"dark\") // valid: dark | light | ansi","handlingStrategy":"validation","validationCode":"var validThemes = []string{\"dark\", \"light\", \"ansi\"}\nfunc isValidTheme(name string) bool {\n\tfor _, t := range validThemes {\n\t\tif t == name {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n// before calling: if !isValidTheme(themeName) { themeName = \"dark\" }","typeGuard":"func knownTheme(name string) (string, bool) {\n\tswitch name {\n\tcase \"dark\", \"light\", \"ansi\":\n\t\treturn name, true\n\t}\n\treturn \"\", false\n}","tryCatchPattern":"theme, err := loadTheme(name)\nif err != nil {\n\tfmt.Fprintf(os.Stderr, \"warning: %v; falling back to default theme %q\\n\", err, defaultThemeName())\n\ttheme, err = loadTheme(defaultThemeName())\n\tif err != nil {\n\t\tfmt.Fprintln(os.Stderr, \"fatal: default theme failed:\", err)\n\t\tos.Exit(1)\n\t}\n}","preventionTips":["Validate the theme flag in CLI arg parsing before invoking loadTheme","Default to defaultThemeName() when the flag is empty or unset","Normalize input (strings.ToLower, strings.TrimSpace) and compare against the whitelist","Keep the accepted theme list documented in --help so users don't guess names","Test config-driven theme values with a fallback path in mind"],"tags":["go","cli","theme","invalid-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"4636deb4a7b707a9f04c602db033f9837e50b3f6","analyzedAt":"2026-09-06T02:31:58.576Z","contentChangedAt":"2026-09-06T02:31:58.576Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}