gotify/server · error
invalid bool for %s (%q): %w
Error message
invalid bool for %s (%q): %w
What it means
parseBool reads the env var and converts it with strconv.ParseBool, which only accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Anything else (yes, on, enabled, empty) yields 'invalid bool for %s (%q): %w'.
Source
Thrown at config/parse.go:64
n, err := strconv.Atoi(raw)
if err != nil {
return fmt.Errorf("invalid int for %s (%q): %w", env, raw, err)
}
*target = n
return nil
}
func parseBool(target *bool, env string) error {
raw, ok, err := lookupEnv(env)
if err != nil {
return err
}
if !ok {
return nil
}
b, err := strconv.ParseBool(raw)
if err != nil {
return fmt.Errorf("invalid bool for %s (%q): %w", env, raw, err)
}
*target = b
return nil
}
func parseList(target *[]string, env string) error {
raw, ok, err := lookupEnv(env)
if err != nil {
return err
}
if !ok {
return nil
}
if raw == "" {
*target = []string{}
return nil
}
reader := csv.NewReader(strings.NewReader(raw))View on GitHub (pinned to 14bfc25627)
Solutions
- Change the value to one strconv.ParseBool accepts: true/false, 1/0, t/f, TRUE/FALSE.
- Strip quotes and whitespace from the value (DEBUG="true" in a shell keeps the quotes).
- If you need yes/no semantics, transform them before config load or change the config schema to a string flag.
- Read the %q raw value in the error to identify invisible characters, then correct the environment definition.
Example fix
// before DEBUG=yes // after DEBUG=true
Defensive patterns
Strategy: validation
Validate before calling
func assertBoolEnv(env string) error {
raw := os.Getenv(env)
if raw == "" { return nil }
if _, err := strconv.ParseBool(strings.TrimSpace(raw)); err != nil {
return fmt.Errorf("%s=%q is not a Go bool (use true/false/1/0)", env, raw)
}
return nil
} Try / catch
if err := config.Get(&cfg); err != nil {
if strings.Contains(err.Error(), "invalid bool for") {
return fmt.Errorf("boolean env vars must be true/false/1/0: %w", err)
}
return err
} Prevention
- Standardize on true/false (or 1/0) for all boolean env vars across services and CI
- Map shell-style truthy values (yes/on) at the source, not in the parser
- Quote consistently: DEBUG=true without quotes in shell/export files
- Add a lint that greps deployment manifests for boolean vars with invalid values
When it happens
Trigger: Calling config.Get with a boolean-typed setting whose env value is 'yes'/'no', 'on'/'off', 'Y'/'N', 'enabled', an empty string, or a value with trailing whitespace or quotes.
Common situations: Developers using shell-style truthy values (DEBUG=yes), CI variables set to 'ON', a _FILE containing a value with a trailing space, or toggles left empty.
Related errors
- invalid int for %s (%q): %w
- read file for %s_FILE (%s): %w
- invalid CSV for %s (%q): %w
- cannot delete internal application
- file with key 'file' must be present
AI-assisted analysis of gotify/server@14bfc25627 (2026-09-05).
Data as JSON: /api/errors/22eefc31a54bb2a9.
Report an issue: GitHub.