t8y2/dbx · error
not connected
Error message
not connected
What it means
validateConnection is a health/verification helper on the server. If the runtime or its driver has never been initialized (no successful open), there is nothing to verify, so it returns 'not connected' instead of attempting a call on a nil driver. It signals an ordering problem: validate was called before open/connect succeeded.
Source
Thrown at agents/drivers/neo4j-go/driver.go:196
}
}
return result
}
func testConnection(params connectParams) error {
driver, err := openDriver(params)
if err != nil {
return err
}
defer driver.Close(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), defaultConnectTimeout)
defer cancel()
return driver.VerifyConnectivity(ctx)
}
func (s *server) validateConnection() error {
if s.runtime == nil || s.runtime.driver == nil {
return errors.New("not connected")
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
return s.runtime.driver.VerifyConnectivity(ctx)
}
func (s *server) databaseName(override string) string {
if value := strings.TrimSpace(override); value != "" {
return value
}
return configuredDatabase(s.params)
}
func configuredDatabase(params connectParams) string {
if value := strings.TrimSpace(params.Database); value != "" {
return value
}
value := strings.TrimPrefix(strings.TrimSpace(params.ConnectionString), "jdbc:")View on GitHub (pinned to c0390bff16)
Solutions
- Call the open/connect flow first and confirm it succeeds before validate_connection.
- Handle the connect error and retry connection until runtime.driver is non-nil.
- If already connected, inspect why s.runtime was reset (close was called, or open failed silently).
Example fix
// before
err := s.validateConnection() // runtime not opened yet
// after
if err := s.open(cfg); err != nil { return err }
err := s.validateConnection() Defensive patterns
Strategy: try-catch
Validate before calling
// check state before calling validate
if s.runtime == nil || s.runtime.driver == nil {
return errors.New("not connected")
} Type guard
func isConnected(s *server) bool {
return s != nil && s.runtime != nil && s.runtime.driver != nil
} Try / catch
if err := s.validateConnection(); err != nil {
if err.Error() == "not connected" {
// open first, then retry validation
if oerr := s.open(cfg); oerr != nil { return oerr }
return s.validateConnection()
}
return err
} Prevention
- Enforce open-before-validate ordering in your client wrapper
- Re-open after any close/dispose instead of reusing stale handles
- Treat 'not connected' as a signal to reconnect, not a fatal bug
When it happens
Trigger: Calling the validate_connection method (or validateConnection) before open_session/openDriver completed successfully, or after a previous close/dispose cleared s.runtime.
Common situations: Startup health checks racing the connect call, retrying validation after a failed connect, reusing a stale server handle after reconnect logic failed.
Related errors
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/a5fceabac9e176d3.
Report an issue: GitHub.