{"record":{"id":"a3a28197179178d4","repo":"matryer/xbar","slug":"malformed-parameters-missing-equals","errorCode":null,"errorMessage":"malformed parameters: missing equals","messagePattern":"malformed parameters: missing equals","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":135,"sourceCode":"\tif err := parseParamStr(&params, paramStr); err != nil {\n\t\treturn text, params, err\n\t}\n\treturn text, params, nil\n}\n\n// parseParamStr parses the parameter string, updating params.\nfunc parseParamStr(params *ItemParams, s string) error {\n\tvar splitStr, endStr string\n\tfor {\n\t\ts = strings.TrimSpace(s)\n\t\tif len(s) == 0 {\n\t\t\treturn nil\n\t\t}\n\t\tsplitStr = `=`\n\t\tendStr = ` `\n\t\ti := strings.Index(s, splitStr)\n\t\tif i < 0 {\n\t\t\treturn errors.New(\"malformed parameters: missing equals\")\n\t\t}\n\t\tif len(s) > i+1 && (s[i+1] == '\"' || s[i+1] == '\\'') {\n\t\t\t// quotes\n\t\t\tendStr = string(s[i+1])\n\t\t\tsplitStr = \"=\" + endStr\n\t\t}\n\t\toffset := i + len(splitStr)\n\t\tkey := s[:i]\n\t\tif key[0] == '|' {\n\t\t\tkey = key[1:]\n\t\t\tkey = strings.TrimSpace(key)\n\t\t}\n\t\tvaluePart := s[offset:]\n\t\tend := strings.Index(valuePart, endStr)\n\t\tif end < 0 {\n\t\t\tend = strings.Index(valuePart, \"|\")\n\t\t}\n\t\tif end < 0 {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L117-L153","documentation":"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.","triggerScenarios":"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 `=`.","commonSituations":"Writing xbar menu item hrefs/params by hand and forgetting `=`; shell-style flags like `--verbose` passed as params; quoting errors that swallow the `=`.","solutions":["Add an equals sign and a value to each parameter token, e.g. `key=value`","Quote values containing spaces: `key=\"value with spaces\"`","Remove non key=value tokens from the parameter list"],"exampleFix":"// before\nparams: \"--verbose\"\n// after\nparams: \"verbose=true\"","handlingStrategy":"validation","validationCode":"// before parsing params: each token must contain '='\nfor _, tok := range strings.Fields(paramStr) {\n    if !strings.Contains(tok, \"=\") {\n        return fmt.Errorf(\"param %q is not key=value\", tok)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Go\nparams, err := plugins.ParseParams(paramStr)\nif err != nil {\n    if strings.Contains(err.Error(), \"missing equals\") {\n        return fmt.Errorf(\"params must be key=value pairs: %w\", err)\n    }\n    return err\n}","preventionTips":["Always write params as key=value tokens","Quote values that contain spaces or special characters","Convert flag-style arguments (--flag) into key=value form","Unit-test param strings with TestParseParamStr-like cases"],"tags":["parsing","validation","plugins"],"backgroundTag":"malformed-key-value-parameter","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}