{"record":{"id":"bbcbb66d6d4ec269","repo":"cayleygraph/cayley","slug":"could-not-retrieve-maxopenconnections-from-options","errorCode":null,"errorMessage":"could not retrieve maxopenconnections from options: %v","messagePattern":"could not retrieve maxopenconnections from options: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/sql/quadstore.go","lineNumber":122,"sourceCode":"\ntype QuadStore struct {\n\tdb      *sql.DB\n\topt     *Optimizer\n\tflavor  Registration\n\tids     *lru.Cache\n\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","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/sql/quadstore.go#L104-L140","documentation":"connect reads the \"maxopenconnections\" integer option with a default of -1 via graph.Options.IntKey. If IntKey returns an error (typically the key exists but is not an integer, per the options API), connect wraps it in \"could not retrieve maxopenconnections from options\" and aborts. Init and New both route through connect.","triggerScenarios":"Calling graph/sql quadstore New(addr, opts) or Init with opts where the \"maxopenconnections\" key is present with a non-integer value (e.g. \"ten\", \"100abc\").","commonSituations":"Config file/env where maxopenconnections is quoted or mistyped; YAML/JSON config feeding strings into IntKey; copy-pasting a boolean or float value into the option.","solutions":["Set \"maxopenconnections\" to a valid integer in the options (or remove the key to use the default).","Inspect the wrapped %v error for the exact IntKey parse failure.","Check the config source for quotes/whitespace making the value a string."],"exampleFix":"// before\nopts{\"maxopenconnections\": \"twenty\"}\n// after\nopts{\"maxopenconnections\": 20}","handlingStrategy":"validation","validationCode":"// before New/Init:\nif v, ok := opts[\"maxopenconnections\"]; ok {\n    if _, err := strconv.Atoi(fmt.Sprint(v)); err != nil {\n        return fmt.Errorf(\"maxopenconnections 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(), \"maxopenconnections\") {\n        // fix the option type/value and retry\n    }\n}","preventionTips":["Keep numeric options as JSON/YAML numbers, not strings.","Use typed option builders instead of raw maps.","Validate the full options map 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-14T00:17:10.932Z"}