matryer/xbar · error
ansi
Error message
ansi
What it means
This error occurs when the "ansi" key in a plugin item's parameter string cannot be parsed as a boolean. setValueByKey calls parseBool for the ansi value and wraps the failure with the key "ansi". It means the ansi= value (controlling ANSI color code processing) is not a valid boolean literal.
Source
Thrown at pkg/plugins/item_params.go:255
return errors.Wrap(err, key)
}
case "alternate":
var err error
p.Alternate, err = parseBool(value)
if err != nil {
return errors.Wrap(err, key)
}
case "emojize":
var err error
p.Emojize, err = parseBool(value)
if err != nil {
return errors.Wrap(err, key)
}
case "ansi":
var err error
p.ANSI, err = parseBool(value)
if err != nil {
return errors.Wrap(err, key)
}
default:
if strings.HasPrefix(key, "param") {
paramIndex, err := strconv.Atoi(key[5:])
if err != nil {
return errors.Errorf("bad parameter: %s (should be paramN)", key)
}
for len(p.ShellParams) < paramIndex {
// ensure the slice is big enough
p.ShellParams = append(p.ShellParams, "")
}
p.ShellParams[paramIndex-1] = value
return nil
}
return errors.Errorf("unknown parameter: %s", key)
}
return nil
}View on GitHub (pinned to d624239058)
Solutions
- Set ansi=true or ansi=false (1/0, t/f also accepted).
- Replace on/off/yes/no style values with true/false.
- Ensure the value is non-empty after '=' in the metadata line.
- Remove the key to accept the default (ansi is true by default).
Example fix
// before params := "ansi=on" // after params := "ansi=true"
Defensive patterns
Strategy: validation
Validate before calling
re := regexp.MustCompile(`ansi=(true|false|1|0|t|f|TRUE|FALSE|True|False|T|F)\b`)
if strings.Contains(params, "ansi=") && !re.MatchString(params) {
return errors.New("ansi must be true or false")
} Type guard
func isGoBool(s string) bool {
_, err := strconv.ParseBool(strings.TrimSpace(s))
return err == nil
} Try / catch
if err := item.ParseParams(raw); err != nil {
if strings.Contains(err.Error(), "ansi") {
log.Printf("bad ansi value in %q: %v; using default", raw, err)
raw = removeParam(raw, "ansi")
}
} Prevention
- Translate on/off habits to true/false when writing ansi=.
- Omit the key entirely to accept the default (ansi defaults to true).
- Trim whitespace from values in hand-edited metadata.
- Check the actual emitted line with your script's debug output.
When it happens
Trigger: Parsing a param string containing 'ansi=on', 'ansi=yes', 'ansi=' (empty), or any value strconv.ParseBool rejects.
Common situations: Authors enabling/disabling ANSI escape handling in terminal output copy on/off conventions from other tools, or leave the value blank when toggling by deleting the word.
Related errors
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/40ad8d961773a961.
Report an issue: GitHub.