{"record":{"id":"40ad8d961773a961","repo":"matryer/xbar","slug":"ansi","errorCode":null,"errorMessage":"ansi","messagePattern":"ansi","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/plugins/item_params.go","lineNumber":255,"sourceCode":"\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 {\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}","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/matryer/xbar/blob/d624239058997c80118eaebe2e7f8331b3c765e0/pkg/plugins/item_params.go#L237-L273","documentation":"This error occurs when the \"ansi\" key in a plugin item's parameter string cannot be parsed as a boolean. setValueByKey calls parseBool for the ansi value and wraps the failure with the key \"ansi\". It means the ansi= value (controlling ANSI color code processing) is not a valid boolean literal.","triggerScenarios":"Parsing a param string containing 'ansi=on', 'ansi=yes', 'ansi=' (empty), or any value strconv.ParseBool rejects.","commonSituations":"Authors enabling/disabling ANSI escape handling in terminal output copy on/off conventions from other tools, or leave the value blank when toggling by deleting the word.","solutions":["Set ansi=true or ansi=false (1/0, t/f also accepted).","Replace on/off/yes/no style values with true/false.","Ensure the value is non-empty after '=' in the metadata line.","Remove the key to accept the default (ansi is true by default)."],"exampleFix":"// before\nparams := \"ansi=on\"\n// after\nparams := \"ansi=true\"","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`ansi=(true|false|1|0|t|f|TRUE|FALSE|True|False|T|F)\\b`)\nif strings.Contains(params, \"ansi=\") && !re.MatchString(params) {\n    return errors.New(\"ansi must be true or false\")\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    if strings.Contains(err.Error(), \"ansi\") {\n        log.Printf(\"bad ansi value in %q: %v; using default\", raw, err)\n        raw = removeParam(raw, \"ansi\")\n    }\n}","preventionTips":["Translate on/off habits to true/false when writing ansi=.","Omit the key entirely to accept the default (ansi defaults to true).","Trim whitespace from values in hand-edited metadata.","Check the actual emitted line with your script's debug output."],"tags":["go","config-parsing","boolean-parse"],"backgroundTag":"invalid-boolean-value","analyzedSha":"d624239058997c80118eaebe2e7f8331b3c765e0","analyzedAt":"2026-09-02T22:38:22.007Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}