{"record":{"id":"ec2f317ea5dfba12","repo":"iflytek/astron-agent","slug":"invalid-database-max-idle-conns-v","errorCode":null,"errorMessage":"invalid DATABASE_MAX_IDLE_CONNS: %v","messagePattern":"invalid DATABASE_MAX_IDLE_CONNS: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tenant/config/env_loader.go","lineNumber":84,"sourceCode":"\tcfg.DataBase.Password = value\n\treturn nil\n}\n\nfunc (l *EnvLoader) setDatabaseURL(cfg *Config, value string) error {\n\tcfg.DataBase.Url = value\n\treturn nil\n}\n\nfunc (l *EnvLoader) setDatabaseMaxOpenConns(cfg *Config, value string) error {\n\tif n, err := fmt.Sscanf(value, \"%d\", &cfg.DataBase.MaxOpenConns); err != nil || n != 1 {\n\t\treturn fmt.Errorf(\"invalid DATABASE_MAX_OPEN_CONNS: %v\", err)\n\t}\n\treturn nil\n}\n\nfunc (l *EnvLoader) setDatabaseMaxIdleConns(cfg *Config, value string) error {\n\tif n, err := fmt.Sscanf(value, \"%d\", &cfg.DataBase.MaxIdleConns); err != nil || n != 1 {\n\t\treturn fmt.Errorf(\"invalid DATABASE_MAX_IDLE_CONNS: %v\", err)\n\t}\n\treturn nil\n}\n\nfunc (l *EnvLoader) setLogPath(cfg *Config, value string) error {\n\tcfg.Log.LogFile = value\n\treturn nil\n}\n\nfunc (l *EnvLoader) Watch(cfg *Config, onChange func()) {\n}\n","sourceCodeStart":66,"sourceCodeEnd":96,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/tenant/config/env_loader.go#L66-L96","documentation":"EnvLoader.setDatabaseMaxIdleConns parses DATABASE_MAX_IDLE_CONNS with fmt.Sscanf(\"%d\") and returns this error when the value is non-empty but not a valid integer. The value configures the DB pool's maximum idle connections, and the error aborts startup via LoadConfig -> EnvLoader.Load.","triggerScenarios":"DATABASE_MAX_IDLE_CONNS is set (non-empty) but unparseable as an integer: e.g. \"10idle\", \"ten\", \"10.5\", or a value with hidden whitespace/control characters at the start.","commonSituations":"Appending units or comments to pool-size numbers in deployment manifests, YAML type coercion issues, hand-edited .env files with typos, or copy-pasting values with trailing descriptions.","solutions":["Set DATABASE_MAX_IDLE_CONNS to a plain integer (e.g. DATABASE_MAX_IDLE_CONNS=10) and restart.","Inspect with `printenv DATABASE_MAX_IDLE_CONNS | cat -A` and remove stray text/units from the manifest.","Keep idle conns a plain integer <= max open conns; drop any floats or units.","Optionally switch the loader to strconv.Atoi for clearer parse errors."],"exampleFix":"// before\nDATABASE_MAX_IDLE_CONNS=10 idle\n// after\nDATABASE_MAX_IDLE_CONNS=10","handlingStrategy":"validation","validationCode":"if v := os.Getenv(\"DATABASE_MAX_IDLE_CONNS\"); v != \"\" {\n\tif n, err := strconv.Atoi(v); err != nil || n < 0 {\n\t\treturn fmt.Errorf(\"DATABASE_MAX_IDLE_CONNS must be a non-negative integer, got %q\", v)\n\t}\n}","typeGuard":null,"tryCatchPattern":"_, err := config.LoadConfig(path)\nif err != nil && strings.HasPrefix(err.Error(), \"invalid DATABASE_MAX_IDLE_CONNS\") {\n\tlog.Fatalf(\"DATABASE_MAX_IDLE_CONNS=%q is not an integer: %v\", os.Getenv(\"DATABASE_MAX_IDLE_CONNS\"), err)\n}","preventionTips":["Set idle conns as a bare integer <= max open conns","Avoid hand-edited .env files; generate them from templates with validated values","Render Helm/Compose output and grep pool vars for correctness in CI","Prefer strconv.Atoi over fmt.Sscanf when writing loaders for clearer errors"],"tags":["configuration","env-var","parsing","database","go"],"backgroundTag":"invalid-env-var-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}