urfave/cli · error
parse error
Error message
parse error
What it means
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.
Source
Thrown at flag_bool.go:62
}
return &boolValue{
destination: p,
count: c.Count,
}
}
// ToString formats the bool value
func (b boolValue) ToString(value bool) string {
b.destination = &value
return b.String()
}
// Below functions are to satisfy the flag.Value interface
func (b *boolValue) Set(s string) error {
v, err := strconv.ParseBool(s)
if err != nil {
err = errors.New("parse error")
return err
}
*b.destination = v
if b.count != nil {
*b.count = *b.count + 1
}
return err
}
func (b *boolValue) Get() any { return *b.destination }
func (b *boolValue) String() string {
return strconv.FormatBool(*b.destination)
}
func (b *boolValue) IsBoolFlag() bool { return true }
View on GitHub (pinned to 1a4deb4f5a)
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.
Example fix
// before myapp -verbose=yes // after myapp -verbose=true
Defensive patterns
Strategy: validation
Validate before calling
func isValidBoolString(s string) bool {
_, err := strconv.ParseBool(s)
return err == nil
}
// call: isValidBoolString(flagValue) before setting/parsing Try / catch
if err := flag.Set("verbose", v); err != nil {
if err.Error() == "parse error" {
fmt.Fprintf(os.Stderr, "-verbose expects true/false, got %q\n", v)
os.Exit(2)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- got nil/empty layouts slice
- invalid value %q for flag -%s: %v
- empty github token
- goimports needed
- invalid value %q for argument %s: %v
AI-assisted analysis of urfave/cli@1a4deb4f5a (2026-08-31).
Data as JSON: /api/errors/48abb0d4f9c56d62.
Report an issue: GitHub.