OtterMind/Chat2DB · error · BusinessException
database.delete.schemaNotExists
database.delete.schemaNotExists
Error message
database.delete.schemaNotExists
What it means
Thrown by assertSchemaExists when the named schema is not present in the database's schema metadata listing (Chat2DBContext.getDbMetaData().schemas(connection, databaseName)). The metadata query succeeds but no Schema.getName() equals the requested schemaName. Prevents dropping a non-existent schema.
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:254
}
private void rejectSystemSchema(String dbType, String schemaName) {
if (DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)) {
String lowerSchemaName = StringUtils.lowerCase(schemaName);
if (POSTGRESQL_SYSTEM_SCHEMAS.contains(lowerSchemaName)
|| StringUtils.startsWith(lowerSchemaName, "pg_toast")
|| StringUtils.startsWith(lowerSchemaName, "pg_temp")) {
throw new BusinessException("database.delete.systemSchemaForbidden");
}
}
}
private void assertSchemaExists(Connection connection, String databaseName, String schemaName) {
List<Schema> schemas = Chat2DBContext.getDbMetaData().schemas(connection, databaseName);
boolean exists = schemas != null && schemas.stream()
.anyMatch(schema -> StringUtils.equals(schema.getName(), schemaName));
if (!exists) {
throw new BusinessException("database.delete.schemaNotExists");
}
}
private String schemaConfirmName(String schemaName) {
return schemaName;
}
private String buildDropSchema(String dbType, String schemaName) {
return Chat2DBContext.getDbMetaData(dbType).getSqlBuilder().ddl().schema().buildDropSchema(schemaName);
}
private void assertConfirmName(String actualConfirmName, String expectedConfirmName) {
if (!StringUtils.equals(actualConfirmName, expectedConfirmName)) {
throw new BusinessException("database.delete.confirmNameMismatch");
}
}
private String maintenanceDatabase() {View on GitHub (pinned to 5ee1e990e7)
Solutions
- Refresh the schema list for the correct databaseName and confirm the schema still exists.
- Verify the databaseName in the request matches the connection's active database.
- Check case sensitivity of the schemaName parameter.
Defensive patterns
Strategy: validation
Validate before calling
List<Schema> schemas = Chat2DBContext.getDbMetaData().schemas(connection, databaseName);
boolean exists = schemas != null && schemas.stream().anyMatch(s -> StringUtils.equals(s.getName(), schemaName));
if (!exists) { /* do not call delete */ } Prevention
- Refresh the schema list for the correct database before confirming.
- Verify the databaseName in the request matches the active connection database.
When it happens
Trigger: Calling prepareSchemaDelete or executeSchemaDelete with a schemaName that does not match any schema returned by schemas(connection, databaseName). Common when the schema was dropped externally or the wrong databaseName was supplied.
Common situations: Schema already deleted in another session; wrong databaseName in the request so the schema list is from a different database; case-sensitivity mismatch.
Related errors
- database.delete.databaseNotExists
- ai.model.config.notFound
- datasource_not_found
- datasource.not.found
- database.delete.notSupportSchema
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/050d6f589fe358a2.
Report an issue: GitHub.