{"record":{"id":"7d1080959f913d52","repo":"matryer/xbar","slug":"expected-true-or-false-not-s","errorCode":null,"errorMessage":"expected \"true\" or \"false\", not \"%s\"","messagePattern":"expected \"true\" or \"false\", not \"(.+?)\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":280,"sourceCode":"\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 {\n\t\treturn false, errors.Errorf(`expected \"true\" or \"false\", not \"%s\"`, s)\n\t}\n\treturn b, nil\n}\n\n// parseColor parses the color value given.\n// Valid values: named color, #RGB, #RGBA, #RRGGBB, #RRGGBBAA.\n// Returns a nice error if it fails.\nfunc parseColor(s string) (string, error) {\n\tif len(s) == 0 {\n\t\treturn \"\", errors.Errorf(\"expected hex string or named color\") // Probably an error?\n\t}\n\ts = strings.ToLower(s)\n\tif s[0] == '#' {\n\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","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L262-L298","documentation":"This error is produced by parseBool when strconv.ParseBool rejects the given string while parsing any boolean item parameter (disabled, terminal, refresh, dropdown, trim, alternate, emojize, ansi). It reports the exact offending value: expected \"true\" or \"false\", not \"<value>\". The caller setValueByKey then wraps it with the key name, so the final message reads like 'refresh: expected \"true\" or \"false\", not \"yes\"'.","triggerScenarios":"Any boolean param key given a value outside strconv.ParseBool's accepted set (true/false/1/0/t/f/TRUE/FALSE/True/False/T/F), including empty strings and values with surrounding whitespace.","commonSituations":"Using yes/no or on/off from YAML/INI habits, leaving a value empty (key=), trailing spaces or invisible characters from hand-edited metadata, and shell scripts interpolating unset variables producing empty values.","solutions":["Replace the value with a valid boolean literal: true or false (1/0, t/f also accepted).","Trim whitespace and remove stray characters from the metadata line.","In generating scripts, emit explicit literals, e.g. printf 'dropdown=%s' \"$([ \"$cond\" ] && echo true || echo false)\".","Remove the key entirely if the default is acceptable."],"exampleFix":"// before\nparams := \"terminal=yes\"\n// after\nparams := \"terminal=true\"","handlingStrategy":"validation","validationCode":"func sanitizeBoolParams(params string) (string, error) {\n    boolKeys := map[string]bool{\"disabled\": true, \"terminal\": true, \"refresh\": true,\n        \"dropdown\": true, \"trim\": true, \"alternate\": true, \"emojize\": true, \"ansi\": true}\n    var out []string\n    for _, kv := range strings.Split(params, \",\") {\n        parts := strings.SplitN(kv, \"=\", 2)\n        if len(parts) == 2 && boolKeys[parts[0]] {\n            if _, err := strconv.ParseBool(strings.TrimSpace(parts[1])); err != nil {\n                return \"\", fmt.Errorf(\"%s: expected true or false, not %q\", parts[0], parts[1])\n            }\n        }\n        out = append(out, kv)\n    }\n    return strings.Join(out, \",\"), nil\n}","typeGuard":"func isGoBool(s string) bool {\n    _, err := strconv.ParseBool(strings.TrimSpace(s))\n    return err == nil\n}","tryCatchPattern":"if err := item.ParseParams(raw); err != nil {\n    // err reads: <key>: expected \"true\" or \"false\", not \"<value>\"\n    if strings.Contains(err.Error(), \"expected \\\"true\\\" or \\\"false\\\"\") {\n        log.Printf(\"boolean param typo in %q: %v\", raw, err)\n        raw = sanitizeBoolParams(stripOffending(raw)) // retry with cleaned params\n    }\n}","preventionTips":["Only ever write true/false (or 1/0, t/f) for the eight boolean keys.","Wrap shell interpolation: emit \"$( [ \"$x\" = y ] && echo true || echo false )\" instead of raw variables.","Trim whitespace and check for invisible characters in hand-edited metadata.","Add a regex lint over plugin output: ^(disabled|terminal|refresh|dropdown|trim|alternate|emojize|ansi)=(true|false|1|0|t|f)$ per key."],"tags":["go","boolean-parse","config-parsing"],"backgroundTag":"invalid-boolean-value","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}