OtterMind/Chat2DB · error · BusinessException

database.delete.invalidDataSource

database.delete.invalidDataSource

Error message

database.delete.invalidDataSource

What it means

Thrown by requireCurrentProfile() when connectionContextService.currentProfile() returns null — there is no active data source profile bound to the context, so no delete operation can proceed.

Source

Thrown at chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbDatabaseObjectDeleteServiceImpl.java:149

        assertConfirmName(param.getConfirmName(), schemaConfirmName(schemaName));
        if (!StringUtils.equals(profile.getDatabaseName(), databaseName)) {
            throw new BusinessException("database.delete.connectionDatabaseMismatch");
        }
        Connection connection = requireConnection();
        try {
            assertSchemaExists(connection, databaseName, schemaName);
            Chat2DBContext.getDbManager(dbType).dropSchema(connection, databaseName, schemaName);
        } catch (BusinessException e) {
            throw e;
        } catch (Exception e) {
            throw new BusinessException("database.delete.executeFailed", new Object[]{e.getMessage()}, e);
        }
    }

    private ConnectionProfile requireCurrentProfile() {
        ConnectionProfile profile = connectionContextService.currentProfile();
        if (profile == null) {
            throw new BusinessException("database.delete.invalidDataSource");
        }
        return profile;
    }

    private String requireSupportedDbType(ConnectionProfile profile) {
        String dbType = StringUtils.upperCase(StringUtils.trimToNull(profile.getDbType()));
        if (!SUPPORTED_TYPES.contains(dbType)) {
            throw new BusinessException("database.delete.notSupportDbType");
        }
        return dbType;
    }

    private void reconnectForDatabaseDelete(String dbType) {
        if (!DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {
            return;
        }
        connectionContextService.rebindCurrentDatabase(maintenanceDatabase());
    }

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Ensure connect() succeeded and a profile is bound before calling any delete method.
  2. Surface a 'select/refresh datasource' prompt to the user when the profile is missing rather than throwing.
  3. Check currentProfile() for null at the controller boundary and return a 400/connect-required response.
Defensive patterns

Strategy: validation

Validate before calling

// Before any delete call
if (connectionContextService.currentProfile() == null) {
    return Result.fail("database.delete.invalidDataSource"); // or a 'connect required' response
}

Prevention

When it happens

Trigger: Any delete prepare/execute method is called before a connection context (and its ConnectionProfile) was established, or after the context was cleared/closed.

Common situations: Delete endpoint invoked without prior connect(); session/context expired; clear() ran earlier in the thread; MCP context not pushed.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/f2830fd26740a21b. Report an issue: GitHub.