matryer/xbar · error

color

Error message

color

What it means

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.

Source

Thrown at pkg/plugins/item_params.go:193

}

func (p *ItemParams) setValueByKey(key, value string) error {
	switch key {
	case "disabled":
		var err error
		p.Disabled, err = parseBool(value)
		if err != nil {
			return errors.Wrap(err, key)
		}
	case "key":
		p.Key = value
	case "href":
		p.Href = value
	case "color":
		var err error
		p.Color, err = parseColor(value)
		if err != nil {
			return errors.Wrap(err, key)
		}
	case "font":
		p.Font = value
	case "size":
		val, err := parseInt(value)
		if err != nil {
			return errors.Wrap(err, key)
		}
		p.Size = val
	case "shell", "bash":
		p.Shell = value
	case "templateImage":
		p.TemplateImage = value
	case "image":
		p.Image = value
	case "terminal":
		var err error
		p.Terminal, err = parseBool(value)

View on GitHub (pinned to d624239058)

Solutions

  1. Use a valid hex color in the expected format, e.g. color=#FF0000, or a recognized color name.
  2. Remove unsupported formats like hsl()/8-digit hex; convert to supported hex or named color.
  3. Check parseColor's accepted format in pkg/plugins and match it exactly.

Example fix

// before
color=redd
// after
color=red
Defensive patterns

Strategy: validation

Validate before calling

var validColor = regexp.MustCompile(`^(#[0-9a-fA-F]{6}|[a-z]+)$`)
func validColorParam(v string) error {
    if !validColor.MatchString(strings.TrimSpace(v)) {
        return fmt.Errorf("invalid color: %q", v)
    }
    return nil
}

Try / catch

params, err := parseParamStr(raw)
if err != nil && strings.HasPrefix(err.Error(), "color:") {
    log.Printf("invalid color value, using default: %v", err)
    params.Color = "" // library default
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02). Data as JSON: /api/errors/aa40eb9e0c36a018. Report an issue: GitHub.