cayleygraph/cayley · error
could not retrieve maxIdleConnections from options: %v
Error message
could not retrieve maxIdleConnections from options: %v
What it means
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.
Source
Thrown at graph/sql/quadstore.go:128
sizes *lru.Cache
noSizes bool
mu sync.RWMutex
nodes int64
quads int64
}
func connect(addr string, flavor string, opts graph.Options) (*sql.DB, error) {
maxOpenConnections, err := opts.IntKey("maxopenconnections", -1)
if err != nil {
return nil, fmt.Errorf("could not retrieve maxopenconnections from options: %v", err)
}
maxIdleConnections, err := opts.IntKey("maxidleconnections", -1)
if err != nil {
return nil, fmt.Errorf("could not retrieve maxIdleConnections from options: %v", err)
}
connMaxLifetime, err := opts.StringKey("connmaxlifetime", "")
if err != nil {
return nil, fmt.Errorf("could not retrieve connmaxlifetime from options: %v", err)
}
var connDuration time.Duration
if connMaxLifetime != "" {
connDuration, err = time.ParseDuration(connMaxLifetime)
if err != nil {
return nil, fmt.Errorf("couldn't parse connmaxlifetime string: %v", err)
}
}
// TODO(barakmich): Parse options for more friendly addrView on GitHub (pinned to 81dcd7d73e)
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.
Example fix
// before
{"maxidleconnections": "five"}
// after
{"maxidleconnections": 5} Defensive patterns
Strategy: validation
Validate before calling
if v, ok := opts["maxidleconnections"]; ok {
if _, err := strconv.Atoi(fmt.Sprint(v)); err != nil {
return fmt.Errorf("maxidleconnections must be an integer, got %v", v)
}
} Try / catch
qs, err := quadstore.New(addr, opts)
if err != nil {
if strings.Contains(err.Error(), "maxIdleConnections") {
// correct the option and retry
}
} Prevention
- 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.
When it happens
Trigger: New/Init call where opts contains "maxidleconnections" with a non-integer value (string, bool, nested value).
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- could not retrieve maxopenconnections from options: %v
- could not retrieve connmaxlifetime from options: %v
- couldn't parse connmaxlifetime string: %v
- Invalid %s parameter type from config: %T
- could not open config file %q: %v
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/62aea67a1a105ba3.
Report an issue: GitHub.