{"record":{"id":"fd4a042e6025b3fb","repo":"OtterMind/Chat2DB","slug":"sqlexecution-streamingunsupported","errorCode":"sqlExecution.streamingUnsupported","errorMessage":"sqlExecution.streamingUnsupported","messagePattern":"sqlExecution\\.streamingUnsupported","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbSqlExecutionServiceImpl.java","lineNumber":30,"sourceCode":"\nimport java.sql.SQLException;\n\n@Service\npublic class DbSqlExecutionServiceImpl implements IDbSqlExecutionService {\n\n    private final IDbSqlCommandService sqlSqlExecuteRequestService;\n\n    public DbSqlExecutionServiceImpl(IDbSqlCommandService sqlSqlExecuteRequestService) {\n        this.sqlSqlExecuteRequestService = sqlSqlExecuteRequestService;\n    }\n\n    @Override\n    public void executeStreaming(DbStreamingExecuteRequest executeStreamingRequest) throws SQLException {\n        SqlExecuteRequest command = sqlSqlExecuteRequestService.toSqlExecuteRequest(\n                executeStreamingRequest.getDlExecuteRequest());\n        ICommandExecutor executor = Chat2DBContext.getDbMetaData().getCommandExecutor();\n        if (!(executor instanceof DefaultSQLExecutor sqlExecutor)) {\n            throw new IllegalStateException(I18nUtils.getMessage(\"sqlExecution.streamingUnsupported\"));\n        }\n        sqlExecutor.executeStreaming(command, executeStreamingRequest.getConsumer(),\n                executeStreamingRequest.getStatementListener(), executeStreamingRequest.getCancellation());\n    }\n\n}\n","sourceCodeStart":12,"sourceCodeEnd":37,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbSqlExecutionServiceImpl.java#L12-L37","documentation":"Thrown by DbSqlExecutionServiceImpl.executeStreaming when Chat2DBContext.getDbMetaData().getCommandExecutor() is not an instance of DefaultSQLExecutor. Streaming execution is implemented only on DefaultSQLExecutor (the instanceof pattern guard narrows to that type before calling executeStreaming); any plugin that supplies a different ICommandExecutor is rejected. Unlike the others this is an IllegalStateException (not BusinessException), resolved directly via I18nUtils.getMessage(\"sqlExecution.streamingUnsupported\") -> 'Current datasource executor does not support streaming SQL execution'. At the web layer it is handled by DefaultExceptionConvertor, so the response body uses the generic common.systemError code even though the message text is the streaming-specific one.","triggerScenarios":"Requesting streaming SQL execution on a datasource whose plugin's metadata returns a custom (non-DefaultSQLExecutor) command executor. The streaming consumer/statement-listener callbacks are only wired for DefaultSQLExecutor.","commonSituations":"A DB type with a specialized executor implementation; calling the streaming endpoint for a connection type that only supports blocking execution; a plugin that wrapped DefaultSQLExecutor instead of extending it.","solutions":["Use streaming execution only for datasources backed by DefaultSQLExecutor; fall back to normal (blocking) execution otherwise.","If streaming is required for the type, make the plugin's command executor a DefaultSQLExecutor (or have executeStreaming delegate to it).","Gate the streaming action in the UI on executor-type capability before sending the request."],"exampleFix":"// before\nICommandExecutor executor = Chat2DBContext.getDbMetaData().getCommandExecutor();\nif (!(executor instanceof DefaultSQLExecutor sqlExecutor)) {\n    throw new IllegalStateException(I18nUtils.getMessage(\"sqlExecution.streamingUnsupported\"));\n}\n\n// after: degrade gracefully instead of hard-failing\nif (!(executor instanceof DefaultSQLExecutor sqlExecutor)) {\n    log.warn(\"streaming unsupported for {}; falling back to blocking execution\", executor.getClass());\n    sqlSqlExecuteRequestService.execute(command);\n    return;\n}","handlingStrategy":"type-guard","validationCode":"ICommandExecutor executor = Chat2DBContext.getDbMetaData().getCommandExecutor();\nif (!(executor instanceof DefaultSQLExecutor)) {\n    // use normal (blocking) execution; do not call executeStreaming\n}","typeGuard":"boolean streamingSupported() {\n    return Chat2DBContext.getDbMetaData().getCommandExecutor() instanceof DefaultSQLExecutor;\n}","tryCatchPattern":"try {\n    service.executeStreaming(req);\n} catch (IllegalStateException e) { // streamingUnsupported\n    // fall back to blocking execution\n}","preventionTips":["Offer streaming only for DefaultSQLExecutor-backed datasources.","Ensure plugin executors extend DefaultSQLExecutor when streaming is desired."],"tags":["streaming","capability-gate","sql-execution","plugin"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}