{"record":{"id":"5e0f29c9670fe2ad","repo":"matryer/xbar","slug":"bad-parameter-s-should-be-paramn","errorCode":null,"errorMessage":"bad parameter: %s (should be paramN)","messagePattern":"bad parameter: (.+?) \\(should be paramN\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":261,"sourceCode":"\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"emojize\":\n\t\tvar err error\n\t\tp.Emojize, err = parseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"ansi\":\n\t\tvar err error\n\t\tp.ANSI, err = parseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tdefault:\n\t\tif strings.HasPrefix(key, \"param\") {\n\t\t\tparamIndex, err := strconv.Atoi(key[5:])\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Errorf(\"bad parameter: %s (should be paramN)\", key)\n\t\t\t}\n\t\t\tfor len(p.ShellParams) < paramIndex {\n\t\t\t\t// ensure the slice is big enough\n\t\t\t\tp.ShellParams = append(p.ShellParams, \"\")\n\t\t\t}\n\t\t\tp.ShellParams[paramIndex-1] = value\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.Errorf(\"unknown parameter: %s\", key)\n\t}\n\treturn nil\n}\n\n// parseBool parses a boolean from a string (either `true` or `false`),\n// returning a nice error if it fails.\nfunc parseBool(s string) (bool, error) {\n\tb, err := strconv.ParseBool(s)\n\tif err != nil {","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L243-L279","documentation":"This error occurs when a param string key starts with \"param\" (so it is treated as a positional shell parameter) but the remainder is not a valid integer, e.g. paramx or paramfoo. setValueByKey strips the 'param' prefix and calls strconv.Atoi; on failure it reports 'bad parameter: <key> (should be paramN)'. Positional params populate p.ShellParams which are passed to the item's shell command.","triggerScenarios":"Parsing a param string containing keys like 'param=value', 'param1a=x', 'param=foo', or 'param01text' — any key with the 'param' prefix whose suffix fails strconv.Atoi. Note param0 is accepted syntactically by Atoi but indexes ShellParams[-1] only after the loop pads the slice, so shell params should be param1, param2, ...","commonSituations":"Authors write 'param=value' thinking it is a named parameter syntax, or make typos like 'parm1' vs 'param1' mix-ups such as 'paraml1' (lowercase L instead of 1). Copy-paste from docs where the N in paramN was not replaced with a number.","solutions":["Use a numeric suffix: param1=..., param2=... instead of param=... or a non-numeric suffix.","Fix typos in the key (e.g. paraml1 -> param11) so the suffix parses as an integer.","If you want an arbitrary named key, it is not supported — pass the value through the shell command directly or use the shell= key.","Start numbering at param1; verify the emitted keys with the actual script output."],"exampleFix":"// before\nparams := \"param=hello\"\n// after\nparams := \"param1=hello\"","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`\\bparam[0-9]+=`)\nfor _, kv := range strings.Split(params, \",\") {\n    k := strings.SplitN(kv, \"=\", 2)[0]\n    if strings.HasPrefix(k, \"param\") && !regexp.MustCompile(`^param[0-9]+$`).MatchString(k) {\n        return fmt.Errorf(\"key %q must be paramN, e.g. param1\", k)\n    }\n}","typeGuard":"var paramKeyRe = regexp.MustCompile(`^param[0-9]+$`)\nfunc isParamKey(k string) bool { return paramKeyRe.MatchString(k) }","tryCatchPattern":"if err := item.ParseParams(raw); err != nil {\n    if strings.Contains(err.Error(), \"bad parameter\") {\n        log.Printf(\"misnamed shell param in %q: %v\", raw, err)\n        return // fix the metadata line\n    }\n}","preventionTips":["Always number shell params: param1=, param2=, starting at 1.","Never write a bare param= key; it is reserved as paramN syntax.","Use a monospace editor to avoid l/1 and O/0 confusion in keys.","Test shell param values reach $1, $2 ... in your shell command."],"tags":["go","config-parsing","shell-params"],"backgroundTag":"invalid-parameter-name","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}