{"record":{"id":"427c30c7bbfb297c","repo":"t8y2/dbx","slug":"getexplaininfo-is-not-supported-by-this-agent","errorCode":null,"errorMessage":"getExplainInfo is not supported by this agent","messagePattern":"getExplainInfo is not supported by this agent","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"agents/common/src/main/java/com/dbx/agent/DatabaseAgent.java","lineNumber":215,"sourceCode":"        );\n    }\n\n    default QueryPageResult fetchTableReadPage(String sessionId, int pageSize) {\n        return AgentExecutionContext.jdbcExecutor().fetchTableReadPage(sessionId, pageSize);\n    }\n\n    default boolean closeTableReadSession(String sessionId) {\n        return AgentExecutionContext.jdbcExecutor().closeTableReadSession(sessionId);\n    }\n\n    /**\n     * Get DM execution plan. Supports two modes:\n     *   mode=\"explain\" (default) — direct plan, no execution\n     *   mode=\"autotrace\"         — enable MONITOR_SQL_EXEC, execute SQL, then get plan with actual stats\n     * @return plan text\n     */\n    default String getExplainInfo(String sql, String database, String schema, int timeoutSecs, String mode) {\n        throw new UnsupportedOperationException(\"getExplainInfo is not supported by this agent\");\n    }\n\n    void disconnect();\n\n    Connection getConnection();\n\n    default QueryResult executeTransaction(List<String> statements, String schema) {\n        Connection conn = getConnection();\n        if (conn == null) {\n            throw new IllegalStateException(\"Not connected\");\n        }\n        return TransactionExecutor.executeUpdateStatements(\n            conn,\n            statements,\n            schema,\n            this::setSchemaSQL,\n            this::resetSchemaSQL\n        );","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/common/src/main/java/com/dbx/agent/DatabaseAgent.java#L197-L233","documentation":"getExplainInfo() (execution-plan retrieval, including DM's explain/autotrace modes) is an optional capability; the interface default throws UnsupportedOperationException. Only agents that can produce execution plans override it, so calling it on a non-supporting agent fails immediately with no plan generated.","triggerScenarios":"Calling getExplainInfo(sql, database, schema, timeoutSecs, mode) on an agent that does not override the default method — e.g. requesting an execution plan for a database whose driver has no EXPLAIN/AUTOTRACE support.","commonSituations":"A 'Show execution plan' button is enabled for every connection type but the underlying agent (non-DM or minimal driver) never implemented plan extraction; feature toggled on for older agent versions that predate getExplainInfo.","solutions":["Feature-detect before calling (instanceof an ExplainCapable interface or capability flag) and disable the plan view when unsupported.","Implement getExplainInfo in the agent using the database's native EXPLAIN/plan facility.","Return a user-facing 'execution plans are not supported for this database type' message instead of the raw exception."],"exampleFix":"// before\nString plan = agent.getExplainInfo(sql, db, schema, 30, \"explain\");\n// after\nif (!(agent instanceof ExplainCapable)) {\n    return \"Execution plan not supported for this database type\";\n}\nString plan = agent.getExplainInfo(sql, db, schema, 30, \"explain\");","handlingStrategy":"type-guard","validationCode":"if (!(agent instanceof ExplainCapable)) { throw new UserFacingError(\"Execution plans are not supported for this database type\"); }","typeGuard":"static boolean supportsExplain(DatabaseAgent a) {\n    return a instanceof ExplainCapable;\n}","tryCatchPattern":"try {\n    return agent.getExplainInfo(sql, db, schema, timeout, mode);\n} catch (UnsupportedOperationException e) {\n    return null; // caller renders 'plan not supported'\n}","preventionTips":["Expose getExplainInfo only behind a capability interface.","Gate the plan-view feature flag on the connected database type.","Test each agent implementation for which optional methods it overrides."],"tags":["unsupported-operation","capability","explain-plan"],"backgroundTag":"feature-not-supported","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"}