{"record":{"id":"cccf84648673d61a","repo":"OtterMind/Chat2DB","slug":"connection-error-cccf84","errorCode":null,"errorMessage":"connection error","messagePattern":"connection error","errorType":"exception","errorClass":"BusinessException","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/DbRoutineOperationServiceImpl.java","lineNumber":29,"sourceCode":"import org.apache.commons.lang3.StringUtils;\nimport org.springframework.stereotype.Service;\n\nimport java.sql.Connection;\n\n@Service\npublic class DbRoutineOperationServiceImpl implements IDbRoutineOperationService {\n\n    @Override\n    public SqlPreview previewInvocation(RoutineOperation operation) {\n        IRoutineManager routineManager = Chat2DBContext.getRoutineManager();\n        if (routineManager == null) {\n            throw new BusinessException(\"routine.operation.onlyMysqlSupported\");\n        }\n        Connection connection = Chat2DBContext.getConnection();\n        if (connection == null) {\n            throw new BusinessException(\"connection error\");\n        }\n        return routineManager.previewInvocation(connection, completeOperation(operation));\n    }\n\n    @Override\n    public SqlPreview previewMigration(RoutineOperation operation) {\n        IRoutineManager routineManager = Chat2DBContext.getRoutineManager();\n        if (routineManager == null) {\n            throw new BusinessException(\"routine.operation.onlyMysqlSupported\");\n        }\n        Connection connection = Chat2DBContext.getConnection();\n        if (connection == null) {\n            throw new BusinessException(\"connection error\");\n        }\n        return routineManager.previewMigration(connection, completeOperation(operation));\n    }\n\n    @Override\n    public ExecuteResponse executeMigration(RoutineOperation operation) {\n        IRoutineManager routineManager = Chat2DBContext.getRoutineManager();","sourceCodeStart":11,"sourceCodeEnd":47,"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/DbRoutineOperationServiceImpl.java#L11-L47","documentation":"Thrown by DbRoutineOperationServiceImpl.previewInvocation when Chat2DBContext.getConnection() returns null, i.e. no live JDBC connection is bound to the current context. NOTE: the code is the literal string 'connection error' (with a space), NOT the i18n key 'connection.error', so it is NOT localized and renders as the raw 'connection error : no message.' This is a defect in the thrown code; the intended key 'connection.error' ('Connection failed, please check the connection information') is never reached on this path.","triggerScenarios":"Calling routine preview without an established datasource connection in the context (connection not opened, dropped, or context not initialized for the request).","commonSituations":"Request scoped outside the connection-establishment flow; a connection that failed to open silently; invoking routine APIs before selecting/connecting a datasource.","solutions":["Ensure a datasource connection is opened and bound in Chat2DBContext before calling routine operations.","Fix the thrown code to 'connection.error' so the localized message surfaces instead of 'connection error : no message.'.","Guard routine calls with a connection-availability check upstream."],"exampleFix":"// before\nthrow new BusinessException(\"connection error\");\n// renders: \"connection error : no message.\"\n\n// after\nthrow new BusinessException(\"connection.error\");\n// renders: \"Connection failed, please check the connection information\"","handlingStrategy":"validation","validationCode":"if (Chat2DBContext.getConnection() == null) {\n    // establish/open the datasource connection before routine operations\n}","typeGuard":"boolean connectionReady() {\n    return Chat2DBContext.getConnection() != null;\n}","tryCatchPattern":null,"preventionTips":["Open the datasource connection before invoking routine APIs.","Fix the thrown code to 'connection.error' for a localized message."],"tags":["connection","routines","i18n-missing-key","context"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}