OtterMind/Chat2DB · error · BusinessException

database.delete.databaseNotExists

database.delete.databaseNotExists

Error message

database.delete.databaseNotExists

What it means

Thrown by assertDatabaseExists when the named database is not found in the server's metadata listing (Chat2DBContext.getDbMetaData(dbType).databases(connection)). The metadata query succeeds but no returned Database has a name equal to the requested databaseName. This guards against dropping a database that was already removed or never existed.

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:208

                && POSTGRESQL_SYSTEM_DATABASES.contains(StringUtils.lowerCase(databaseName))) {
            throw new BusinessException("database.delete.systemDatabaseForbidden");
        }
    }

    private Connection requireConnection() {
        Connection connection = Chat2DBContext.getConnection();
        if (connection == null) {
            throw new BusinessException("database.delete.connectionFailed");
        }
        return connection;
    }

    private void assertDatabaseExists(Connection connection, String dbType, String databaseName) {
        List<Database> databases = Chat2DBContext.getDbMetaData(dbType).databases(connection);
        boolean exists = databases != null && databases.stream()
                .anyMatch(database -> StringUtils.equals(database.getName(), databaseName));
        if (!exists) {
            throw new BusinessException("database.delete.databaseNotExists");
        }
    }

    private DatabaseObjectDeletePrepare prepareResult(String confirmName, String sqlPreview, String objectType,
                                                       String dbType) {
        return DatabaseObjectDeletePrepare.builder()
                .confirmName(confirmName)
                .sqlPreview(sqlPreview)
                .objectType(objectType)
                .dbType(dbType)
                .build();
    }

    private String databaseConfirmName(String databaseName) {
        return databaseName;
    }

    private String buildDropDatabase(String dbType, String databaseName) {

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Refresh the database list and confirm the database still exists before retrying.
  2. Check for exact case sensitivity in the databaseName parameter.
  3. If already deleted externally, no action is needed — report success/idempotency to the user.
Defensive patterns

Strategy: validation

Validate before calling

List<Database> dbs = Chat2DBContext.getDbMetaData(dbType).databases(connection);
boolean exists = dbs != null && dbs.stream().anyMatch(d -> StringUtils.equals(d.getName(), databaseName));
if (!exists) { /* do not call delete */ }

Prevention

When it happens

Trigger: Calling prepareDatabaseDelete or executeDatabaseDelete with a databaseName that does not match any Database.getName() returned by the dialect's databases() metadata call. Common when the database was dropped by another session between listing and confirmation.

Common situations: Race condition: database deleted by another admin between the UI listing and the user confirming; typo or wrong-case database name; metadata listing filtered or cached and stale.

Related errors


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