matryer/xbar · error
expected "true" or "false", not "%s"
Error message
expected "true" or "false", not "%s"
What it means
This error is produced by parseBool when strconv.ParseBool rejects the given string while parsing any boolean item parameter (disabled, terminal, refresh, dropdown, trim, alternate, emojize, ansi). It reports the exact offending value: expected "true" or "false", not "<value>". The caller setValueByKey then wraps it with the key name, so the final message reads like 'refresh: expected "true" or "false", not "yes"'.
Source
Thrown at pkg/plugins/item_params.go:280
}
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
}
// parseBool parses a boolean from a string (either `true` or `false`),
// returning a nice error if it fails.
func parseBool(s string) (bool, error) {
b, err := strconv.ParseBool(s)
if err != nil {
return false, errors.Errorf(`expected "true" or "false", not "%s"`, s)
}
return b, nil
}
// parseColor parses the color value given.
// Valid values: named color, #RGB, #RGBA, #RRGGBB, #RRGGBBAA.
// Returns a nice error if it fails.
func parseColor(s string) (string, error) {
if len(s) == 0 {
return "", errors.Errorf("expected hex string or named color") // Probably an error?
}
s = strings.ToLower(s)
if s[0] == '#' {
// Matches #RGB #RGBA #RRGGBB #RRGGBBAA
if !colorRegexp.Match([]byte(s)) {
return "", errors.Errorf(`invalid hex format "%s"`, s)
}
return s, nilView on GitHub (pinned to d624239058)
Solutions
- Replace the value with a valid boolean literal: true or false (1/0, t/f also accepted).
- Trim whitespace and remove stray characters from the metadata line.
- In generating scripts, emit explicit literals, e.g. printf 'dropdown=%s' "$([ "$cond" ] && echo true || echo false)".
- Remove the key entirely if the default is acceptable.
Example fix
// before params := "terminal=yes" // after params := "terminal=true"
Defensive patterns
Strategy: validation
Validate before calling
func sanitizeBoolParams(params string) (string, error) {
boolKeys := map[string]bool{"disabled": true, "terminal": true, "refresh": true,
"dropdown": true, "trim": true, "alternate": true, "emojize": true, "ansi": true}
var out []string
for _, kv := range strings.Split(params, ",") {
parts := strings.SplitN(kv, "=", 2)
if len(parts) == 2 && boolKeys[parts[0]] {
if _, err := strconv.ParseBool(strings.TrimSpace(parts[1])); err != nil {
return "", fmt.Errorf("%s: expected true or false, not %q", parts[0], parts[1])
}
}
out = append(out, kv)
}
return strings.Join(out, ","), nil
} 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 {
// err reads: <key>: expected "true" or "false", not "<value>"
if strings.Contains(err.Error(), "expected \"true\" or \"false\"") {
log.Printf("boolean param typo in %q: %v", raw, err)
raw = sanitizeBoolParams(stripOffending(raw)) // retry with cleaned params
}
} Prevention
- Only ever write true/false (or 1/0, t/f) for the eight boolean keys.
- Wrap shell interpolation: emit "$( [ "$x" = y ] && echo true || echo false )" instead of raw variables.
- Trim whitespace and check for invisible characters in hand-edited metadata.
- Add a regex lint over plugin output: ^(disabled|terminal|refresh|dropdown|trim|alternate|emojize|ansi)=(true|false|1|0|t|f)$ per key.
When it happens
Trigger: Any boolean param key given a value outside strconv.ParseBool's accepted set (true/false/1/0/t/f/TRUE/FALSE/True/False/T/F), including empty strings and values with surrounding whitespace.
Common situations: Using yes/no or on/off from YAML/INI habits, leaving a value empty (key=), trailing spaces or invisible characters from hand-edited metadata, and shell scripts interpolating unset variables producing empty values.
Related errors
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/7d1080959f913d52.
Report an issue: GitHub.