{"record":{"id":"066bead18583b840","repo":"matryer/xbar","slug":"expected-an-int-not-s","errorCode":null,"errorMessage":"expected an int, not \"%s\"","messagePattern":"expected an int, not \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":312,"sourceCode":"\t\t// Matches #RGB #RGBA #RRGGBB #RRGGBBAA\n\t\tif !colorRegexp.Match([]byte(s)) {\n\t\t\treturn \"\", errors.Errorf(`invalid hex format \"%s\"`, s)\n\t\t}\n\t\treturn s, nil\n\t}\n\thexValue, valid := namedColors[s]\n\tif !valid {\n\t\treturn \"\", errors.Errorf(`invalid named color \"%s\"`, s)\n\t}\n\treturn hexValue, nil\n}\n\n// parseInt parses an int from a string, returning a nice\n// error if it fails.\nfunc parseInt(s string) (int, error) {\n\ti, err := strconv.ParseInt(s, 10, 64)\n\tif err != nil {\n\t\treturn 0, errors.Errorf(`expected an int, not \"%s\"`, s)\n\t}\n\treturn int(i), nil\n}\n\n// truncate shrinks a string if it's too long.\nfunc truncate(s string, max int) string {\n\ttruncated, err := ansi.Truncate(s, max-1)\n\tif err != nil {\n\t\t// If, for some reason, there's an error when\n\t\t// parsing, do what we used to do\n\t\trunes := []rune(s)\n\t\tif max > 0 && len(runes) > max {\n\t\t\ts = string(runes[:max-1]) + \"…\"\n\t\t}\n\t\treturn s\n\t}\n\tlength, _ := ansi.Length(truncated)\n\tif length == max-1 {","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L294-L330","documentation":"parseInt converts a plugin parameter value (e.g. dropdown widths, trim lengths) into an int using strconv.ParseInt in base 10. This error is thrown when the string is not a valid integer, with the offending value included in the message.","triggerScenarios":"setValueByKey receives a non-numeric value for an int parameter — e.g. | length=abc, | dropdown=true, | size=10px, an empty value, or a value with thousands separators like 1,000.","commonSituations":"Plugin authors passing suffixed numbers (px, %), booleans or floats (1.5) where a plain int is expected; shell variables containing text; locale-formatted numbers with separators.","solutions":["Supply a plain base-10 integer, e.g. | length=42","Strip unit suffixes in the plugin script: ${SIZE%px} or size=$((size))","Round floats to integers before emitting the parameter","Guard unset variables with a default: ${LENGTH:-0}"],"exampleFix":"// before\necho \"Item | length=${WIDTH%px}\"   // '10px' -> 10 fails if suffix remains\n// after\nLENGTH=${WIDTH%px}; echo \"Item | length=${LENGTH:-0}\"","handlingStrategy":"validation","validationCode":"n, err := strconv.Atoi(strings.TrimSpace(val))\nif err != nil {\n    val = \"0\" // sanitize before emitting the parameter\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit bare base-10 integers only — no suffixes, commas or decimals","Default numeric variables: ${LEN:-0}","Pre-strip unit suffixes (px, %) in the plugin script"],"tags":["plugins","parameters","integer","parsing"],"backgroundTag":"invalid-integer-parse","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}