{"record":{"id":"e41655b4d44dd56b","repo":"OtterMind/Chat2DB","slug":"connection-error","errorCode":"connection error","errorMessage":"connection error","messagePattern":"connection error","errorType":"error_code","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/DbAccountAdminServiceImpl.java","lineNumber":62,"sourceCode":"    }\n\n    @Override\n    public AccountExecuteResponse execute(AccountOperationRequest command) {\n        return requireAccountManager().execute(requireConnection(), command);\n    }\n\n    private IAccountManager requireAccountManager() {\n        IAccountManager accountManager = Chat2DBContext.getAccountManager();\n        if (accountManager == null) {\n            throw new BusinessException(\"account.manage.unsupported\");\n        }\n        return accountManager;\n    }\n\n    private Connection requireConnection() {\n        Connection connection = Chat2DBContext.getConnection();\n        if (connection == null) {\n            throw new BusinessException(\"connection error\");\n        }\n        return connection;\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":67,"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/DbAccountAdminServiceImpl.java#L44-L67","documentation":"Thrown by requireConnection() when Chat2DBContext.getConnection() returns null, meaning no JDBC connection is bound to the current request's thread-local context. The account admin service needs a live connection to enumerate/manage DB accounts. Note the code key is the literal string 'connection error' (with a space); the i18n catalog only defines 'connection.error' (dotted), so the message likely renders raw rather than as 'Connection failed, please check the connection information'.","triggerScenarios":"Calling any account-management API on DbAccountAdminServiceImpl (e.g. list/create/drop DB users) before a connection context was opened via DbConnectionContextServiceImpl.connect(), or after it was cleared/closed mid-request. Also when requireAccountManager() passes but the connection itself was never bound.","commonSituations":"A controller endpoint invoked without the connection-context middleware having run (missing @Connect interceptor), a prior connect() that failed silently, or clear()/close() called earlier in the same thread. Race between MCP context setup and an account call.","solutions":["Ensure DbConnectionContextServiceImpl.connect(...) ran successfully on the current thread before invoking account-admin methods; check that connectInfo was actually pushed via Chat2DBContext.putContext.","If you restructured request scoping, verify the interceptor/filter that calls connect() still precedes account endpoints.","Fix the message key mismatch: use 'connection.error' (dotted) so the i18n message resolves, since BusinessException.code is looked up verbatim."],"exampleFix":"// before\nthrow new BusinessException(\"connection error\");\n// after\nthrow new BusinessException(\"connection.error\");","handlingStrategy":"validation","validationCode":"// Before invoking any account-admin method:\nif (Chat2DBContext.getConnection() == null) {\n    // open a connection context first, or return a 'connect required' response\n    dbConnectionContextService.connect(connectRequest);\n}\nif (Chat2DBContext.getConnection() == null) {\n    return Result.fail(\"connection.error\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always establish the connection context (connect()) before account-management calls.","Add an interceptor that asserts Chat2DBContext.getConnection() is non-null on account endpoints.","Fix the message key to the dotted 'connection.error' so failures are localized."],"tags":["connection","context","account","i18n"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}