{"record":{"id":"a5fceabac9e176d3","repo":"t8y2/dbx","slug":"not-connected-a5fcea","errorCode":null,"errorMessage":"not connected","messagePattern":"not connected","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/neo4j-go/driver.go","lineNumber":196,"sourceCode":"\t\t}\n\t}\n\treturn result\n}\n\nfunc testConnection(params connectParams) error {\n\tdriver, err := openDriver(params)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer driver.Close(context.Background())\n\tctx, cancel := context.WithTimeout(context.Background(), defaultConnectTimeout)\n\tdefer cancel()\n\treturn driver.VerifyConnectivity(ctx)\n}\n\nfunc (s *server) validateConnection() error {\n\tif s.runtime == nil || s.runtime.driver == nil {\n\t\treturn errors.New(\"not connected\")\n\t}\n\tctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\treturn s.runtime.driver.VerifyConnectivity(ctx)\n}\n\nfunc (s *server) databaseName(override string) string {\n\tif value := strings.TrimSpace(override); value != \"\" {\n\t\treturn value\n\t}\n\treturn configuredDatabase(s.params)\n}\n\nfunc configuredDatabase(params connectParams) string {\n\tif value := strings.TrimSpace(params.Database); value != \"\" {\n\t\treturn value\n\t}\n\tvalue := strings.TrimPrefix(strings.TrimSpace(params.ConnectionString), \"jdbc:\")","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/neo4j-go/driver.go#L178-L214","documentation":"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.","triggerScenarios":"Calling the validate_connection method (or validateConnection) before open_session/openDriver completed successfully, or after a previous close/dispose cleared s.runtime.","commonSituations":"Startup health checks racing the connect call, retrying validation after a failed connect, reusing a stale server handle after reconnect logic failed.","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)."],"exampleFix":"// before\nerr := s.validateConnection() // runtime not opened yet\n// after\nif err := s.open(cfg); err != nil { return err }\nerr := s.validateConnection()","handlingStrategy":"try-catch","validationCode":"// check state before calling validate\nif s.runtime == nil || s.runtime.driver == nil {\n    return errors.New(\"not connected\")\n}","typeGuard":"func isConnected(s *server) bool {\n    return s != nil && s.runtime != nil && s.runtime.driver != nil\n}","tryCatchPattern":"if err := s.validateConnection(); err != nil {\n    if err.Error() == \"not connected\" {\n        // open first, then retry validation\n        if oerr := s.open(cfg); oerr != nil { return oerr }\n        return s.validateConnection()\n    }\n    return err\n}","preventionTips":["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"],"tags":["neo4j","connection","lifecycle","state"],"backgroundTag":"not-connected","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}