{"record":{"id":"285f6b4efd3f9062","repo":"matryer/xbar","slug":"length","errorCode":null,"errorMessage":"length","messagePattern":"length","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":230,"sourceCode":"\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"refresh\":\n\t\tvar err error\n\t\tp.Refresh, err = parseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"dropdown\":\n\t\tvar err error\n\t\tp.Dropdown, err = parseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"length\":\n\t\tval, err := parseInt(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\t\tp.Length = val\n\tcase \"trim\":\n\t\tvar err error\n\t\tp.Trim, err = parseBool(value)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, key)\n\t\t}\n\tcase \"alternate\":\n\t\tvar err error\n\t\tp.Alternate, err = parseBool(value)\n\t\tif err != nil {\n\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 {","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L212-L248","documentation":"This error occurs when the \"length\" key in a plugin item's parameter string cannot be parsed as an integer. setValueByKey calls parseInt for the length value and wraps any failure with the key \"length\". It means the length= value used to truncate item text is not a valid integer.","triggerScenarios":"Parsing a param string containing 'length=abc', 'length=10px', 'length=' (empty), or 'length=3.5' via parseParamStr — anything strconv.Atoi rejects.","commonSituations":"Developers set a max character length for menu bar text and accidentally include units (px, chars), decimals, or leave the value empty after deleting a number during editing.","solutions":["Change the value to a plain integer, e.g. length=30.","Remove units or decimal points (length=10px -> length=10).","Ensure a non-empty numeric value follows '='; if truncation is not wanted, remove the length key entirely rather than leaving it blank.","If the value is computed at runtime, format it with a plain integer (e.g. printf 'length=%d' \"$n\") instead of string interpolation that may inject units."],"exampleFix":"// before\nparams := \"length=20px\"\n// after\nparams := \"length=20\"","handlingStrategy":"validation","validationCode":"if v := getParam(params, \"length\"); v != \"\" {\n    if _, err := strconv.Atoi(strings.TrimSpace(v)); err != nil {\n        return fmt.Errorf(\"length must be a plain integer, got %q\", v)\n    }\n}","typeGuard":"func isInt(s string) bool {\n    _, err := strconv.Atoi(strings.TrimSpace(s))\n    return err == nil\n}","tryCatchPattern":"if err := item.ParseParams(raw); err != nil {\n    if strings.Contains(err.Error(), \"length\") {\n        log.Printf(\"bad length in %q: %v; dropping key\", raw, err)\n        raw = removeParam(raw, \"length\")\n    }\n}","preventionTips":["Emit length as a bare integer with no units or decimals.","Format computed values with %d in printf instead of string interpolation.","Delete the length key entirely rather than leaving length= empty.","Add a lint check that all numeric params match ^-?[0-9]+$."],"tags":["go","config-parsing","integer-parse"],"backgroundTag":"invalid-integer-value","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}