{"record":{"id":"22eefc31a54bb2a9","repo":"gotify/server","slug":"invalid-bool-for-s-q-w","errorCode":null,"errorMessage":"invalid bool for %s (%q): %w","messagePattern":"invalid bool for (.+?) \\(%q\\): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/parse.go","lineNumber":64,"sourceCode":"\tn, err := strconv.Atoi(raw)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid int for %s (%q): %w\", env, raw, err)\n\t}\n\t*target = n\n\treturn nil\n}\n\nfunc parseBool(target *bool, env string) error {\n\traw, ok, err := lookupEnv(env)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !ok {\n\t\treturn nil\n\t}\n\tb, err := strconv.ParseBool(raw)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid bool for %s (%q): %w\", env, raw, err)\n\t}\n\t*target = b\n\treturn nil\n}\n\nfunc parseList(target *[]string, env string) error {\n\traw, ok, err := lookupEnv(env)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !ok {\n\t\treturn nil\n\t}\n\tif raw == \"\" {\n\t\t*target = []string{}\n\t\treturn nil\n\t}\n\treader := csv.NewReader(strings.NewReader(raw))","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/gotify/server/blob/14bfc256276775c425f988d621dccfe705de18ac/config/parse.go#L46-L82","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nDEBUG=yes\n// after\nDEBUG=true","handlingStrategy":"validation","validationCode":"func assertBoolEnv(env string) error {\n    raw := os.Getenv(env)\n    if raw == \"\" { return nil }\n    if _, err := strconv.ParseBool(strings.TrimSpace(raw)); err != nil {\n        return fmt.Errorf(\"%s=%q is not a Go bool (use true/false/1/0)\", env, raw)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := config.Get(&cfg); err != nil {\n    if strings.Contains(err.Error(), \"invalid bool for\") {\n        return fmt.Errorf(\"boolean env vars must be true/false/1/0: %w\", err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["go","config","env","boolean","strconv"],"backgroundTag":"invalid-env-value","analyzedSha":"14bfc256276775c425f988d621dccfe705de18ac","analyzedAt":"2026-09-05T12:52:36.781Z","contentChangedAt":"2026-09-05T12:52:36.781Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}