{"record":{"id":"e662fe3003a74fac","repo":"kovidgoyal/kitty","slug":"not-a-valid-color-name-v","errorCode":null,"errorMessage":"not a valid color name: %#v","messagePattern":"not a valid color name: %#v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tools/utils/style/wrapper.go","lineNumber":208,"sourceCode":"\tif strings.HasPrefix(color, \"#\") {\n\t\t// For hex colors, only strip comments after whitespace\n\t\tparts := strings.Fields(color)\n\t\tif len(parts) > 0 {\n\t\t\tcolor = parts[0] // Keep only the hex color part\n\t\t}\n\t} else {\n\t\t// For non-hex colors, strip everything after #\n\t\tif idx := strings.Index(color, \"#\"); idx >= 0 {\n\t\t\tcolor = strings.TrimSpace(color[:idx])\n\t\t}\n\t}\n\n\traw := strings.TrimSpace(strings.ToLower(color))\n\tif val, ok := ColorNames[raw]; ok {\n\t\treturn val, nil\n\t}\n\tif len(raw) < 4 {\n\t\treturn RGBA{}, fmt.Errorf(\"not a valid color name: %#v\", color)\n\t}\n\tvar parser func(string) (RGBA, error)\n\tswitch raw[0] {\n\tcase '#':\n\t\tparser = parse_sharp\n\t\traw = raw[1:]\n\tcase 'o':\n\t\tif strings.HasPrefix(raw, \"oklch(\") {\n\t\t\tparser, raw = parseOklch, raw[6:]\n\t\t}\n\tcase 'l':\n\t\tif strings.HasPrefix(raw, \"lab(\") {\n\t\t\tparser, raw = parseLab, raw[4:]\n\t\t}\n\tcase 'r':\n\t\tif len(raw) > 4 && strings.HasPrefix(raw, \"rgb\") {\n\t\t\traw = raw[3:]\n\t\t\tswitch raw[0] {","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/kovidgoyal/kitty/blob/6d5d0c440603ad9bdf6dcd599f73f6dde21acb44/tools/utils/style/wrapper.go#L190-L226","documentation":"Raised by ParseColor when the input (trimmed, lowercased) is neither a key in the ColorNames map nor long enough (≥4 chars) to possibly be a structured color. Short strings that aren't known color names can never match any of the structured parsers, so they are rejected immediately.","triggerScenarios":"ParseColor(\"abc\") (3 chars, not a known name), ParseColor(\"\"), ParseColor(\" # \") after trimming, or a 1–3 character typo like \"rd\" instead of \"red\".","commonSituations":"Typos in named colors, empty values from unset config/env variables, or strings that were mangled by earlier processing (e.g. comment-stripping removing most of the input).","solutions":["Check for empty/unset color variables before calling ParseColor (e.g. missing env var produced \"\").","Use a known color name from ColorNames (red, green, ...) for short values.","For structured formats, ensure the string is at least 4 characters (e.g. \"#fff\" + prefix requirements).","Trim input and log the offending value when the error occurs."],"exampleFix":"// before\ncol, err := style.ParseColor(os.Getenv(\"ACCENT\")) // ACCENT unset → \"\"\n\n// after\nv := strings.TrimSpace(os.Getenv(\"ACCENT\"))\nif v == \"\" { v = \"red\" }\ncol, err := style.ParseColor(v)","handlingStrategy":"validation","validationCode":"func nonEmptyColorName(s string) bool {\n\treturn len(strings.TrimSpace(s)) > 0\n}","typeGuard":null,"tryCatchPattern":"if _, err := style.ParseColor(v); err != nil {\n\treturn fmt.Errorf(\"invalid color %q: %w\", v, err)\n}","preventionTips":["Default empty/unset env or config values before parsing.","Check membership in style.ColorNames for short named colors.","Trim input at the boundary."],"tags":["color","unknown-name","validation","styling"],"backgroundTag":"color-parse-failed","analyzedSha":"6d5d0c440603ad9bdf6dcd599f73f6dde21acb44","analyzedAt":"2026-08-27T14:20:20.142Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}