matryer/xbar · error

malformed parameters: missing equals

Error message

malformed parameters: missing equals

What it means

This is a malformed-input guard in parseParamStr: while parsing an item's parameter string into key/value pairs, the scanner could not find an '=' separating a key from its value (strings.Index of "=" returned -1). It fires when a parameter token such as "foo" (without "foo=bar" syntax) appears in the params=... attribute of a menu item, or when quoting/scanning desynchronizes the parser.

Source

Thrown at pkg/plugins/item_params.go:135

	if err := parseParamStr(&params, paramStr); err != nil {
		return text, params, err
	}
	return text, params, nil
}

// parseParamStr parses the parameter string, updating params.
func parseParamStr(params *ItemParams, s string) error {
	var splitStr, endStr string
	for {
		s = strings.TrimSpace(s)
		if len(s) == 0 {
			return nil
		}
		splitStr = `=`
		endStr = ` `
		i := strings.Index(s, splitStr)
		if i < 0 {
			return errors.New("malformed parameters: missing equals")
		}
		if len(s) > i+1 && (s[i+1] == '"' || s[i+1] == '\'') {
			// quotes
			endStr = string(s[i+1])
			splitStr = "=" + endStr
		}
		offset := i + len(splitStr)
		key := s[:i]
		if key[0] == '|' {
			key = key[1:]
			key = strings.TrimSpace(key)
		}
		valuePart := s[offset:]
		end := strings.Index(valuePart, endStr)
		if end < 0 {
			end = strings.Index(valuePart, "|")
		}
		if end < 0 {

View on GitHub (pinned to d624239058)

Solutions

  1. Add an equals sign and a value to each parameter token, e.g. `key=value`
  2. Quote values containing spaces: `key="value with spaces"`
  3. Remove non key=value tokens from the parameter list

Example fix

// before
params: "--verbose"
// after
params: "verbose=true"
Defensive patterns

Strategy: validation

Validate before calling

// before parsing params: each token must contain '='
for _, tok := range strings.Fields(paramStr) {
    if !strings.Contains(tok, "=") {
        return fmt.Errorf("param %q is not key=value", tok)
    }
}

Try / catch

// Go
params, err := plugins.ParseParams(paramStr)
if err != nil {
    if strings.Contains(err.Error(), "missing equals") {
        return fmt.Errorf("params must be key=value pairs: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling parseParams (e.g. from TestParseParamStr or menu item parsing) on a parameter string token that lacks an equals sign, such as `param= value` tokens like `foo` or `foo bar` with no `=`.

Common situations: Writing xbar menu item hrefs/params by hand and forgetting `=`; shell-style flags like `--verbose` passed as params; quoting errors that swallow the `=`.

Understand the failure class

Related errors


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