matryer/xbar · error

trim

Error message

trim

What it means

This error occurs when the "trim" key in a plugin item's parameter string cannot be parsed as a boolean. setValueByKey calls parseBool for the trim value and wraps the failure with the key "trim". It means the trim= value controlling whitespace trimming of item text is not a valid boolean literal.

Source

Thrown at pkg/plugins/item_params.go:237

			return errors.Wrap(err, key)
		}
	case "dropdown":
		var err error
		p.Dropdown, err = parseBool(value)
		if err != nil {
			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)

View on GitHub (pinned to d624239058)

Solutions

  1. Use trim=true or trim=false (1/0, t/f also accepted).
  2. Remove trailing punctuation or whitespace from the value.
  3. Ensure shell variables feeding the value are set and expand to true/false, otherwise the emitted value is empty.
  4. Remove the trim key entirely if you want the default (trim is true by default).

Example fix

// before
params := "trim=off"
// after
params := "trim=false"
Defensive patterns

Strategy: validation

Validate before calling

func validBoolParam(params string, key string) bool {
    for _, kv := range strings.Split(params, ",") {
        parts := strings.SplitN(kv, "=", 2)
        if len(parts) == 2 && parts[0] == key {
            _, err := strconv.ParseBool(parts[1])
            return err == nil
        }
    }
    return true
}
// validBoolParam("trim=on", "trim") == false

Type guard

func isGoBool(s string) bool {
    _, err := strconv.ParseBool(s)
    return err == nil
}

Try / catch

if err := item.ParseParams(raw); err != nil {
    if strings.Contains(err.Error(), "trim") {
        log.Printf("invalid trim value in %q: %v", raw, err)
        return // skip item or use defaults
    }
}

Prevention

When it happens

Trigger: Parsing a param string containing 'trim=on', 'trim=false.', 'trim=' (empty), or any value strconv.ParseBool rejects.

Common situations: Plugin authors hand-edit metadata and use yes/off or add stray punctuation/whitespace; templated scripts that emit an empty value (trim=) when a variable is unset also hit this.

Related errors


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