matryer/xbar · error

dropdown

Error message

dropdown

What it means

This error occurs when the "dropdown" key in a plugin item's parameter string cannot be parsed as a boolean. setValueByKey calls parseBool for the dropdown value; on failure the parse error ('expected "true" or "false", not "<value>"') is wrapped with the key "dropdown". It indicates the dropdown= value is not a valid boolean literal.

Source

Thrown at pkg/plugins/item_params.go:225

	case "image":
		p.Image = value
	case "terminal":
		var err error
		p.Terminal, err = parseBool(value)
		if err != nil {
			return errors.Wrap(err, key)
		}
	case "refresh":
		var err error
		p.Refresh, err = parseBool(value)
		if err != nil {
			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)

View on GitHub (pinned to d624239058)

Solutions

  1. Set dropdown to a valid boolean: dropdown=true or dropdown=false (1/0, t/f also accepted).
  2. Strip whitespace and ensure a non-empty value follows the '=' in the metadata line.
  3. If the value is generated dynamically, coerce it to Go-style true/false before writing the params string.
  4. If it should be an arbitrary string, it does not belong under the dropdown key — use paramN instead.

Example fix

// before
params := "dropdown=yes"
// after
params := "dropdown=true"
Defensive patterns

Strategy: validation

Validate before calling

re := regexp.MustCompile(`dropdown=(true|false|1|0|t|f|TRUE|FALSE|True|False|T|F)\b`)
if !re.MatchString(params) {
    return fmt.Errorf("dropdown value must be true/false, got %q", params)
}

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(), "dropdown") {
        log.Printf("invalid dropdown value in %q: %v", raw, err)
        params = defaultParams // fall back to defaults
    }
}

Prevention

When it happens

Trigger: Parsing a param string like 'dropdown=show', 'dropdown=1 ', 'dropdown=' (empty), or 'dropdown=yes' via parseParamStr — any value strconv.ParseBool rejects.

Common situations: Plugin authors control whether an item appears in the dropdown menu and copy conventions like yes/on from YAML or shell configs; trailing whitespace from hand-edited metadata lines and empty values after '=' are the usual culprits.

Related errors


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