{"record":{"id":"48abb0d4f9c56d62","repo":"urfave/cli","slug":"parse-error","errorCode":null,"errorMessage":"parse error","messagePattern":"parse error","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"flag_bool.go","lineNumber":62,"sourceCode":"\t}\n\treturn &boolValue{\n\t\tdestination: p,\n\t\tcount:       c.Count,\n\t}\n}\n\n// ToString formats the bool value\nfunc (b boolValue) ToString(value bool) string {\n\tb.destination = &value\n\treturn b.String()\n}\n\n// Below functions are to satisfy the flag.Value interface\n\nfunc (b *boolValue) Set(s string) error {\n\tv, err := strconv.ParseBool(s)\n\tif err != nil {\n\t\terr = errors.New(\"parse error\")\n\t\treturn err\n\t}\n\t*b.destination = v\n\tif b.count != nil {\n\t\t*b.count = *b.count + 1\n\t}\n\treturn err\n}\n\nfunc (b *boolValue) Get() any { return *b.destination }\n\nfunc (b *boolValue) String() string {\n\treturn strconv.FormatBool(*b.destination)\n}\n\nfunc (b *boolValue) IsBoolFlag() bool { return true }\n","sourceCodeStart":44,"sourceCodeEnd":79,"githubUrl":"https://github.com/urfave/cli/blob/1a4deb4f5a35ee12706602698dc0527d44c14b19/flag_bool.go#L44-L79","documentation":"This error is returned by (*boolValue).Set when the string supplied for a boolean flag cannot be parsed by strconv.ParseBool. Go only accepts \"1\", \"t\", \"T\", \"TRUE\", \"true\", \"True\", \"0\", \"f\", \"F\", \"FALSE\", \"false\", \"False\" for booleans, so any other value is rejected and replaced with this opaque \"parse error\" message. The original strconv error text is discarded, which makes the cause less obvious to users.","triggerScenarios":"Calling Set with a value outside strconv.ParseBool's accepted set, e.g. flag parsing receives -verbose=yes, -verbose=on, or an empty string. It surfaces whenever a BoolFlag's Set method is invoked through command-line parsing or programmatically via flag.Set.","commonSituations":"Users writing shell conventions (-flag=yes/no), scripts setting flags from environment variables with values like \"YES\" or \"on\", or CI configs passing truthy strings the stdlib does not recognize.","solutions":["Use one of the accepted values: true/false, t/f, 1/0, or capitalized variants (TRUE, True, False).","If you need yes/no or on/off semantics, use a string flag and convert it yourself, or a custom flag.Value implementation.","Check the shell script/CI variable feeding the flag for unexpected values like \"yes\", \"on\", or whitespace."],"exampleFix":"// before\nmyapp -verbose=yes\n// after\nmyapp -verbose=true","handlingStrategy":"validation","validationCode":"func isValidBoolString(s string) bool {\n\t_, err := strconv.ParseBool(s)\n\treturn err == nil\n}\n// call: isValidBoolString(flagValue) before setting/parsing","typeGuard":null,"tryCatchPattern":"if err := flag.Set(\"verbose\", v); err != nil {\n\tif err.Error() == \"parse error\" {\n\t\tfmt.Fprintf(os.Stderr, \"-verbose expects true/false, got %q\\n\", v)\n\t\tos.Exit(2)\n\t}\n\treturn err\n}","preventionTips":["Only pass strconv.ParseBool-accepted strings (true/false/1/0/t/f).","Prefer string flags plus explicit conversion for yes/no/on/off semantics.","Test flag invocations from scripts/CI with the exact values that will be used."],"tags":["go","flag-parsing","boolean"],"backgroundTag":"invalid-flag-value","analyzedSha":"1a4deb4f5a35ee12706602698dc0527d44c14b19","analyzedAt":"2026-08-31T18:42:09.451Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}