matryer/xbar · error
alternate
Error message
alternate
What it means
This error occurs when the "alternate" key in a plugin item's parameter string cannot be parsed as a boolean. setValueByKey calls parseBool for the alternate value and wraps the failure with the key "alternate". It means the alternate= value (controlling alternate dropdown-line display) is not a valid boolean literal.
Source
Thrown at pkg/plugins/item_params.go:243
return errors.Wrap(err, key)
}
case "length":
val, err := parseInt(value)
if err != nil {
return errors.Wrap(err, key)
}
p.Length = val
case "trim":
var err error
p.Trim, err = parseBool(value)
if err != nil {
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)View on GitHub (pinned to d624239058)
Solutions
- Set alternate=true or alternate=false (1/0, t/f also accepted).
- Fix stray characters or whitespace around the value.
- Guard the emitting script so it writes a literal true/false instead of an empty or unexpanded value.
- Remove the key if you want the default behavior.
Example fix
// before params := "alternate=yes" // after params := "alternate=true"
Defensive patterns
Strategy: validation
Validate before calling
re := regexp.MustCompile(`alternate=(true|false|1|0|t|f|TRUE|FALSE|True|False|T|F)\b`)
if strings.Contains(params, "alternate=") && !re.MatchString(params) {
return errors.New("alternate 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(), "alternate") {
log.Printf("bad alternate value in %q: %v", raw, err)
raw = removeParam(raw, "alternate")
}
} Prevention
- Write alternate=true/false; do not copy yes/no from YAML configs.
- When toggling by editing metadata, replace the whole value instead of deleting letters.
- Keep generated param strings free of surrounding whitespace.
- Test scripts with unset flag variables to catch empty emissions.
When it happens
Trigger: Parsing a param string containing 'alternate=yes', 'alternate=TRUE.' with stray characters, 'alternate=' (empty), or any other non-boolean value.
Common situations: Authors toggling alternate line display copy conventions from YAML (yes/no) or JSON (true with quotes stripped), or scripts emit an empty value when a flag variable is unset.
Related errors
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/e393ba8873b005fd.
Report an issue: GitHub.