{"record":{"id":"62aea67a1a105ba3","repo":"cayleygraph/cayley","slug":"could-not-retrieve-maxidleconnections-from-options","errorCode":null,"errorMessage":"could not retrieve maxIdleConnections from options: %v","messagePattern":"could not retrieve maxIdleConnections from options: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/sql/quadstore.go","lineNumber":128,"sourceCode":"\tsizes   *lru.Cache\n\tnoSizes bool\n\n\tmu    sync.RWMutex\n\tnodes int64\n\tquads int64\n}\n\nfunc connect(addr string, flavor string, opts graph.Options) (*sql.DB, error) {\n\tmaxOpenConnections, err := opts.IntKey(\"maxopenconnections\", -1)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not retrieve maxopenconnections from options: %v\", err)\n\t}\n\n\tmaxIdleConnections, err := opts.IntKey(\"maxidleconnections\", -1)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not retrieve maxIdleConnections from options: %v\", err)\n\t}\n\n\tconnMaxLifetime, err := opts.StringKey(\"connmaxlifetime\", \"\")\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not retrieve connmaxlifetime from options: %v\", err)\n\t}\n\n\tvar connDuration time.Duration\n\tif connMaxLifetime != \"\" {\n\t\tconnDuration, err = time.ParseDuration(connMaxLifetime)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"couldn't parse connmaxlifetime string: %v\", err)\n\t\t}\n\t}\n\n\t// TODO(barakmich): Parse options for more friendly addr","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/sql/quadstore.go#L110-L146","documentation":"connect reads the \"maxidleconnections\" integer option via graph.Options.IntKey (default -1). A non-integer value makes IntKey fail and connect wraps it as \"could not retrieve maxIdleConnections from options\". Reached via Init or New.","triggerScenarios":"New/Init call where opts contains \"maxidleconnections\" with a non-integer value (string, bool, nested value).","commonSituations":"Misquoted or mistyped values in a database config file; environment-variable-driven configs that pass raw strings; typo producing a value of the wrong type in the Options map.","solutions":["Provide \"maxidleconnections\" as an integer, or omit the key to use the default.","Read the wrapped underlying error to confirm the parse failure.","Sanitize config loading so numeric fields aren't delivered as strings."],"exampleFix":"// before\n{\"maxidleconnections\": \"five\"}\n// after\n{\"maxidleconnections\": 5}","handlingStrategy":"validation","validationCode":"if v, ok := opts[\"maxidleconnections\"]; ok {\n    if _, err := strconv.Atoi(fmt.Sprint(v)); err != nil {\n        return fmt.Errorf(\"maxidleconnections must be an integer, got %v\", v)\n    }\n}","typeGuard":null,"tryCatchPattern":"qs, err := quadstore.New(addr, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"maxIdleConnections\") {\n        // correct the option and retry\n    }\n}","preventionTips":["Ensure maxidleconnections is an integer in config files.","Don't quote numeric values in YAML/JSON configs consumed by typed loaders.","Validate options before calling New/Init."],"tags":["sql","options","config"],"backgroundTag":"invalid-config-value","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}