{"record":{"id":"34495e6bdb439e06","repo":"t8y2/dbx","slug":"agent-is-not-connected","errorCode":null,"errorMessage":"agent is not connected","messagePattern":"agent is not connected","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/oracle-go/main.go","lineNumber":1497,"sourceCode":"\t\treturn jdbcURLInfo{Kind: \"service\", Host: match[1], Port: parsePort(match[2]), Database: match[3]}\n\t}\n\tif match := oracleJDBCSIDRegexp.FindStringSubmatch(value); len(match) == 4 {\n\t\treturn jdbcURLInfo{Kind: \"sid\", Host: match[1], Port: parsePort(match[2]), Database: match[3]}\n\t}\n\tif match := oracleJDBCLegacyRegexp.FindStringSubmatch(value); len(match) == 4 {\n\t\treturn jdbcURLInfo{Kind: \"service\", Host: match[1], Port: parsePort(match[2]), Database: match[3]}\n\t}\n\treturn jdbcURLInfo{}\n}\n\nfunc parsePort(value string) int {\n\tport, _ := strconv.Atoi(value)\n\treturn port\n}\n\nfunc (s *server) requireDB() (*sql.DB, error) {\n\tif s.db == nil {\n\t\treturn nil, errors.New(\"agent is not connected\")\n\t}\n\treturn s.db, nil\n}\n\nfunc (s *server) listDatabases() ([]databaseInfo, error) {\n\trows, err := s.queryRows(oracleListDatabasesSQL, nil)\n\tif err != nil {\n\t\tif isOraclePGALimitError(err) {\n\t\t\treturn s.currentSchemaDatabase()\n\t\t}\n\t\treturn nil, err\n\t}\n\tdefer s.closeRows(rows)\n\tvar result []databaseInfo\n\tfor rows.Next() {\n\t\tvar name string\n\t\tif err := rows.Scan(&name); err != nil {\n\t\t\treturn nil, err","sourceCodeStart":1479,"sourceCodeEnd":1515,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/oracle-go/main.go#L1479-L1515","documentation":"requireDB returns this error when the agent's *sql.DB handle (s.db) is nil — the agent has no live database connection. Every query, explain, and transaction operation funnels through requireDB, so any RPC issued before a successful connect (or after a disconnect/close) fails with this message.","triggerScenarios":"Issuing any RPC (listDatabases, executeQuery, getExplainInfo, executeTransaction, etc.) before calling connect; after an explicit disconnect; after the agent restarted and its connection pool was not re-established.","commonSituations":"Client startup ordering bug where queries race the connect call; agent restarted by a supervisor while clients keep their old handles; a failed connect silently swallowed and then queries attempted anyway.","solutions":["Call the connect RPC with valid DSN/credentials before any other RPC","If the agent was restarted, reconnect and re-run initialization","Check the connect call's error return — a failed connect leaves s.db nil","Add client-side state tracking so queries are queued until the connection is ready"],"exampleFix":"// before\nrows := await driver.executeQuery(\"SELECT 1\") // errors: agent is not connected\n// after\nif (!driver.isConnected()) {\n  await driver.connect(dsn)\n}\nrows := await driver.executeQuery(\"SELECT 1\")","handlingStrategy":"validation","validationCode":"if (!driver.isConnected()) {\n  await driver.connect(dsn) // or queue/fail the request locally\n}","typeGuard":"function isConnected(d) {\n  return d != null && typeof d.hasManualTransaction === 'function' && d._connected === true\n}","tryCatchPattern":null,"preventionTips":["Always await connect() and check its error before issuing queries","Serialize startup: no RPCs until the connection-ready signal fires","Detect agent restarts and re-run connect automatically","Surface connect failures instead of swallowing them"],"tags":["oracle","connection","lifecycle"],"backgroundTag":"agent-not-connected","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}