yudai/gotty · error
invalid bool expression: %v, use true/false
Error message
invalid bool expression: %v, use true/false
What it means
ApplyDefaultValues() reflects over config struct fields and converts each field's default value string to the field's type. For reflect.Bool fields, only the exact strings "true" and "false" are accepted; anything else returns this error, aborting config loading.
Source
Thrown at utils/default.go:28
func ApplyDefaultValues(struct_ interface{}) (err error) {
o := structs.New(struct_)
for _, field := range o.Fields() {
defaultValue := field.Tag("default")
if defaultValue == "" {
continue
}
var val interface{}
switch field.Kind() {
case reflect.String:
val = defaultValue
case reflect.Bool:
if defaultValue == "true" {
val = true
} else if defaultValue == "false" {
val = false
} else {
return fmt.Errorf("invalid bool expression: %v, use true/false", defaultValue)
}
case reflect.Int:
val, err = strconv.Atoi(defaultValue)
if err != nil {
return err
}
default:
val = field.Value()
}
field.Set(val)
}
return nil
}
View on GitHub (pinned to a080c85cbc)
Solutions
- Use exactly true or false (lowercase) in ~/.gotty or the config file
- Replace yes/no or 1/0 with true/false
- Check capitalization — "True"/"FALSE" are rejected
Example fix
// before permit_write = yes // after permit_write = true
Defensive patterns
Strategy: validation
Validate before calling
func validBool(s string) bool { return s == "true" || s == "false" }
// check config values for bool options before ApplyDefaultValues Try / catch
if err := utils.ApplyDefaultValues(options, defaults); err != nil {
if strings.Contains(err.Error(), "invalid bool expression") {
log.Fatalf("config bool value must be true/false: %v", err)
}
} Prevention
- Use lowercase true/false only in ~/.gotty
- Never use yes/no, 1/0, or capitalized True/FALSE
- Lint config files for bool options before deployment
When it happens
Trigger: A config file (or default-value registration) supplies a boolean option a value other than true/false — e.g. yes, no, 1, 0, on, off, True.
Common situations: Users migrating from YAML/INI tools that accept yes/no; writing `True` with a capital letter; using 1/0 as seen in other CLI tools.
Related errors
- failed to compile regular expression of Websocket Origin: %s
- failed to setup TLS configuration
- could not open CA crt file %s
- Error: No command given.
AI-assisted analysis of yudai/gotty@a080c85cbc (2026-09-02).
Data as JSON: /api/errors/ee8762792f6d7476.
Report an issue: GitHub.