{"record":{"id":"1a58ac557b90eb5e","repo":"gotify/server","slug":"invalid-int-for-s-q-w","errorCode":null,"errorMessage":"invalid int for %s (%q): %w","messagePattern":"invalid int for (.+?) \\(%q\\): %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/parse.go","lineNumber":48,"sourceCode":"\t\treturn err\n\t}\n\tif ok {\n\t\t*target = raw\n\t}\n\treturn nil\n}\n\nfunc parseInt(target *int, 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\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","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/gotify/server/blob/14bfc256276775c425f988d621dccfe705de18ac/config/parse.go#L30-L66","documentation":"parseInt reads the env var (directly or via _FILE) and converts it with strconv.Atoi. Any value that is not a plain decimal integer produces 'invalid int for %s (%q): %w', naming the variable, the offending raw value, and the underlying strconv error.","triggerScenarios":"Calling config.Get with an integer-typed setting whose env value is empty, contains spaces, uses underscores or thousands separators ('1_000'), has a unit suffix ('8080ms', '5GB'), or is a quoted string from a _FILE with a trailing newline that survived if only \\r\\n were expected... (note lookupEnv trims \\r\\n; other whitespace remains).","commonSituations":"Setting PORT to 'localhost:8080' instead of a number, timeouts written as '30s' instead of an int, secrets files with extra whitespace, or pasting values with surrounding quotes.","solutions":["Set the env var to a plain base-10 integer (e.g. PORT=8080, TIMEOUT=30).","Strip surrounding whitespace/quotes from the value or from the _FILE contents.","Convert duration/unit values to their integer form before assigning the env var.","Log the %q-quoted raw value from the error to spot invisible characters, then fix the deployment config."],"exampleFix":"// before\nPORT=8080ms\n// after\nPORT=8080","handlingStrategy":"validation","validationCode":"func assertIntEnv(env string) error {\n    raw := os.Getenv(env)\n    if raw == \"\" { return nil }\n    if _, err := strconv.Atoi(strings.TrimSpace(raw)); err != nil {\n        return fmt.Errorf(\"%s=%q is not an integer\", env, raw)\n    }\n    return nil\n}\n// assertIntEnv(\"PORT\") before config.Get","typeGuard":null,"tryCatchPattern":"if err := config.Get(&cfg); err != nil {\n    var perr *strconv.NumError\n    if strings.Contains(err.Error(), \"invalid int for\") {\n        return fmt.Errorf(\"fix the integer env var in your deployment: %w\", err)\n    }\n    _ = perr\n    return err\n}","preventionTips":["Set integer env vars as bare base-10 numbers; no units, separators, or quotes","Strip whitespace when writing _FILE secrets (printf, not echo with padding)","Validate all env vars in CI with a startup smoke test","Read the %q raw value in the error to catch invisible characters"],"tags":["go","config","env","parsing","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"}