{"record":{"id":"aa40eb9e0c36a018","repo":"matryer/xbar","slug":"color","errorCode":null,"errorMessage":"color","messagePattern":"color","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":193,"sourceCode":"}\n\nfunc (p *ItemParams) setValueByKey(key, value string) error {\n\tswitch key {\n\tcase \"disabled\":\n\t\tvar err error\n\t\tp.Disabled, err = parseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"key\":\n\t\tp.Key = value\n\tcase \"href\":\n\t\tp.Href = value\n\tcase \"color\":\n\t\tvar err error\n\t\tp.Color, err = parseColor(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"font\":\n\t\tp.Font = value\n\tcase \"size\":\n\t\tval, err := parseInt(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\t\tp.Size = val\n\tcase \"shell\", \"bash\":\n\t\tp.Shell = value\n\tcase \"templateImage\":\n\t\tp.TemplateImage = value\n\tcase \"image\":\n\t\tp.Image = value\n\tcase \"terminal\":\n\t\tvar err error\n\t\tp.Terminal, err = parseBool(value)","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L175-L211","documentation":"Returned by ItemParams.setValueByKey when the 'color' parameter value fails parseColor validation. The error is wrapped with the key name, yielding 'color: ...'. Colors must be in a format the library accepts; anything else aborts parsing of the parameter string.","triggerScenarios":"parseParamStr encounters key 'color' with a value parseColor rejects — e.g. color=redd, color=#GGGGGG (invalid hex), color=rgb(1,2,3) if unsupported, or an empty value.","commonSituations":"Typos in color names; using hex without the expected format; copying CSS colors (e.g. 'hsl(...)', 8-digit hex) not supported by the plugin parser.","solutions":["Use a valid hex color in the expected format, e.g. color=#FF0000, or a recognized color name.","Remove unsupported formats like hsl()/8-digit hex; convert to supported hex or named color.","Check parseColor's accepted format in pkg/plugins and match it exactly."],"exampleFix":"// before\ncolor=redd\n// after\ncolor=red","handlingStrategy":"validation","validationCode":"var validColor = regexp.MustCompile(`^(#[0-9a-fA-F]{6}|[a-z]+)$`)\nfunc validColorParam(v string) error {\n    if !validColor.MatchString(strings.TrimSpace(v)) {\n        return fmt.Errorf(\"invalid color: %q\", v)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"params, err := parseParamStr(raw)\nif err != nil && strings.HasPrefix(err.Error(), \"color:\") {\n    log.Printf(\"invalid color value, using default: %v\", err)\n    params.Color = \"\" // library default\n}","preventionTips":["Use named colors or 6-digit hex (#RRGGBB) matching parseColor's format.","Avoid CSS-only formats (hsl(), rgba(), 8-digit hex) unless supported.","Trim whitespace; validate colors when generating configs programmatically."],"tags":["go","parsing","plugin-params","color"],"backgroundTag":"invalid-color-value","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}