{"record":{"id":"205234cc60929c66","repo":"matryer/xbar","slug":"invalid-named-color-s","errorCode":null,"errorMessage":"invalid named color \"%s\"","messagePattern":"invalid named color \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":302,"sourceCode":"\n// parseColor parses the color value given.\n// Valid values: named color, #RGB, #RGBA, #RRGGBB, #RRGGBBAA.\n// Returns a nice error if it fails.\nfunc parseColor(s string) (string, error) {\n\tif len(s) == 0 {\n\t\treturn \"\", errors.Errorf(\"expected hex string or named color\") // Probably an error?\n\t}\n\ts = strings.ToLower(s)\n\tif s[0] == '#' {\n\t\t// Matches #RGB #RGBA #RRGGBB #RRGGBBAA\n\t\tif !colorRegexp.Match([]byte(s)) {\n\t\t\treturn \"\", errors.Errorf(`invalid hex format \"%s\"`, s)\n\t\t}\n\t\treturn s, nil\n\t}\n\thexValue, valid := namedColors[s]\n\tif !valid {\n\t\treturn \"\", errors.Errorf(`invalid named color \"%s\"`, s)\n\t}\n\treturn hexValue, nil\n}\n\n// parseInt parses an int from a string, returning a nice\n// error if it fails.\nfunc parseInt(s string) (int, error) {\n\ti, err := strconv.ParseInt(s, 10, 64)\n\tif err != nil {\n\t\treturn 0, errors.Errorf(`expected an int, not \"%s\"`, s)\n\t}\n\treturn int(i), nil\n}\n\n// truncate shrinks a string if it's too long.\nfunc truncate(s string, max int) string {\n\ttruncated, err := ansi.Truncate(s, max-1)\n\tif err != nil {","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L284-L320","documentation":"If the color value does not start with '#', parseColor looks it up in the namedColors map. This error means the value is neither a supported hex literal nor a recognized named color. Note the value is lower-cased before lookup, so casing is not the issue.","triggerScenarios":"setValueByKey passes a non-'#' value absent from namedColors — e.g. color=blurple, color=rgb(255,0,0), color=#-less misspellings like color=grey vs an unsupported name, or locale words like color=rouge.","commonSituations":"Using CSS colors the library doesn't define (rebeccapurple), using rgb()/hsl() notation instead of hex or named colors, typos such as 'rad' or 'bleu'.","solutions":["Use one of the library's supported named colors (red, blue, green, black, white, yellow, magenta, cyan, purple, etc.)","Switch to hex notation, e.g. color=#8A2BE2 for a custom color","Check spelling of the color name; lookup is case-insensitive but exact-match on the name"],"exampleFix":"// before\necho \"Item | color=rebeccapurple\"   // not in namedColors\n// after\necho \"Item | color=#663399\"         // equivalent hex","handlingStrategy":"validation","validationCode":"var named = map[string]bool{\"black\":true,\"red\":true,\"green\":true,\"yellow\":true,\"blue\":true,\"magenta\":true,\"cyan\":true,\"white\":true}\nif !strings.HasPrefix(color, \"#\") && !named[strings.ToLower(color)] {\n    color = \"#\" + color // or fall back to a known named color\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stick to well-known basic color names","Use hex for anything custom","Remember rgb()/hsl() notation is not supported — convert to hex"],"tags":["plugins","parameters","color","validation"],"backgroundTag":"invalid-named-color","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}