OtterMind/Chat2DB · error · BusinessException
connection error
connection error
Error message
connection error
What it means
Thrown by rebindCurrentDatabase() when Chat2DBContext.getConnectInfo() is null — there is no active ConnectInfo on the thread to rebind to a new database. The space-separated key 'connection error' will not resolve against the dotted i18n property 'connection.error'.
Source
Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbConnectionContextServiceImpl.java:82
Chat2DBContext.putContext(connectInfo);
}
}
@Override
public void bindMcp(McpConnectionContextRequest param) {
Chat2DBContext.putContext(buildMcpConnectInfo(param));
}
@Override
public void clear() {
Chat2DBContext.removeContext();
}
@Override
public void rebindCurrentDatabase(String databaseName) {
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
if (connectInfo == null) {
throw new BusinessException("connection error");
}
Chat2DBContext.removeContext();
connectInfo.setDatabaseName(databaseName);
connectInfo.setConnection(null);
Chat2DBContext.putContext(connectInfo);
}
@Override
public void close() {
Chat2DBContext.close();
}
@Override
public ConnectionProfile currentProfile() {
ConnectInfo connectInfo = Chat2DBContext.getConnectInfo();
if (connectInfo == null) {
return null;
}View on GitHub (pinned to 5ee1e990e7)
Solutions
- Ensure connect() succeeded and pushed a ConnectInfo before calling rebindCurrentDatabase().
- If the context can legitimately be absent, treat it as 'must connect first' and surface a connect prompt rather than throwing.
- Fix the key to 'connection.error' so the i18n message resolves correctly.
Example fix
// before
throw new BusinessException("connection error");
// after
throw new BusinessException("connection.error"); Defensive patterns
Strategy: validation
Validate before calling
// Before switching database
if (Chat2DBContext.getConnectInfo() == null) {
// no active connection: require connect() first
return Result.fail("connection.error");
}
dbConnectionContextService.rebindCurrentDatabase(databaseName); Prevention
- Ensure connect() ran and pushed a ConnectInfo before any switch-database call.
- Guard the switch endpoint so a missing context returns 'connect required' instead of throwing.
- Use the dotted 'connection.error' key so the message resolves.
When it happens
Trigger: A database switch request (switching the active database on the current connection) arrives when no connection context exists — e.g. switch-database called before connect(), or after clear()/close() ran.
Common situations: Frontend sends a 'switch database' action for a datasource that was never connected, or after the session/context expired; MCP rebind invoked out of order.
Related errors
- connection error
- datasource.not.found
- connection error
- No database connection context found. Call list_all_datasour
- No database connection context found. Provide dataSourceId/d
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/42019830ac5dfd86.
Report an issue: GitHub.