matryer/xbar · error
expected an int, not "%s"
Error message
expected an int, not "%s"
What it means
parseInt converts a plugin parameter value (e.g. dropdown widths, trim lengths) into an int using strconv.ParseInt in base 10. This error is thrown when the string is not a valid integer, with the offending value included in the message.
Source
Thrown at pkg/plugins/item_params.go:312
// Matches #RGB #RGBA #RRGGBB #RRGGBBAA
if !colorRegexp.Match([]byte(s)) {
return "", errors.Errorf(`invalid hex format "%s"`, s)
}
return s, nil
}
hexValue, valid := namedColors[s]
if !valid {
return "", errors.Errorf(`invalid named color "%s"`, s)
}
return hexValue, nil
}
// parseInt parses an int from a string, returning a nice
// error if it fails.
func parseInt(s string) (int, error) {
i, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return 0, errors.Errorf(`expected an int, not "%s"`, s)
}
return int(i), nil
}
// truncate shrinks a string if it's too long.
func truncate(s string, max int) string {
truncated, err := ansi.Truncate(s, max-1)
if err != nil {
// If, for some reason, there's an error when
// parsing, do what we used to do
runes := []rune(s)
if max > 0 && len(runes) > max {
s = string(runes[:max-1]) + "…"
}
return s
}
length, _ := ansi.Length(truncated)
if length == max-1 {View on GitHub (pinned to d624239058)
Solutions
- Supply a plain base-10 integer, e.g. | length=42
- Strip unit suffixes in the plugin script: ${SIZE%px} or size=$((size))
- Round floats to integers before emitting the parameter
- Guard unset variables with a default: ${LENGTH:-0}
Example fix
// before
echo "Item | length=${WIDTH%px}" // '10px' -> 10 fails if suffix remains
// after
LENGTH=${WIDTH%px}; echo "Item | length=${LENGTH:-0}" Defensive patterns
Strategy: validation
Validate before calling
n, err := strconv.Atoi(strings.TrimSpace(val))
if err != nil {
val = "0" // sanitize before emitting the parameter
} Prevention
- Emit bare base-10 integers only — no suffixes, commas or decimals
- Default numeric variables: ${LEN:-0}
- Pre-strip unit suffixes (px, %) in the plugin script
When it happens
Trigger: setValueByKey receives a non-numeric value for an int parameter — e.g. | length=abc, | dropdown=true, | size=10px, an empty value, or a value with thousands separators like 1,000.
Common situations: Plugin authors passing suffixed numbers (px, %), booleans or floats (1.5) where a plain int is expected; shell variables containing text; locale-formatted numbers with separators.
Related errors
- malformed xbar.var format (default not in select options)
- unknown xbar.var type: %s
- malformed parameters: missing equals
- error decoding plugin %s
- size
AI-assisted analysis of matryer/xbar@d624239058 (2026-09-02).
Data as JSON: /api/errors/066bead18583b840.
Report an issue: GitHub.