OtterMind/Chat2DB · error · BusinessException
database.delete.${fieldName}Required
database.delete.${fieldName}Required
Error message
database.delete.${fieldName}Required What it means
Thrown by requireName() when the supplied name (databaseName or schemaName) trims to null. The code key is built dynamically: 'database.delete.' + fieldName + 'Required', yielding 'database.delete.databaseNameRequired' or 'database.delete.schemaNameRequired' (both have i18n entries).
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:172
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());
}
private String requireName(String name, String fieldName) {
String trimmed = StringUtils.trimToNull(name);
if (trimmed == null) {
throw new BusinessException("database.delete." + fieldName + "Required");
}
return trimmed;
}
private void assertDatabaseDeletionSupported(String dbType) {
DBConfig dbConfig = Chat2DBContext.getDBConfig(dbType);
if (dbConfig == null || !dbConfig.isSupportDatabase()) {
throw new BusinessException("database.delete.notSupportDatabase");
}
}
private void rejectSystemDatabase(String dbType, String databaseName) {
if (DatabaseTypeEnum.MYSQL.name().equalsIgnoreCase(dbType)
&& MYSQL_SYSTEM_DATABASES.contains(StringUtils.lowerCase(databaseName))) {
throw new BusinessException("database.delete.systemDatabaseForbidden");
}
if (DatabaseTypeEnum.POSTGRESQL.name().equalsIgnoreCase(dbType)
&& POSTGRESQL_SYSTEM_DATABASES.contains(StringUtils.lowerCase(databaseName))) {View on GitHub (pinned to 5ee1e990e7)
Solutions
- Validate that databaseName and schemaName (where applicable) are non-blank on the client before submitting.
- Add bean-validation (@NotBlank) on the request DTO so the framework rejects blanks earlier with a clear error.
- Confirm the request payload field names match the DTO (databaseName/schemaName).
Example fix
// before
private String requireName(String name, String fieldName) {
String trimmed = StringUtils.trimToNull(name);
if (trimmed == null) throw new BusinessException("database.delete." + fieldName + "Required");
return trimmed;
}
// after (DTO-level guard so it never reaches the service)
public class DbDatabaseDeleteRequest {
@NotBlank(message = "{database.delete.databaseNameRequired}")
private String databaseName;
} Defensive patterns
Strategy: validation
Validate before calling
// DTO-level guard so blanks never reach the service
if (StringUtils.isBlank(param.getDatabaseName())) {
return Result.fail("database.delete.databaseNameRequired");
}
if (requiresSchema && StringUtils.isBlank(param.getSchemaName())) {
return Result.fail("database.delete.schemaNameRequired");
} Prevention
- Add @NotBlank bean validation on databaseName/schemaName request fields.
- Validate non-blank names on the client before submitting.
- Ensure request payload field names match the DTO.
When it happens
Trigger: prepareDatabaseDelete/prepareSchemaDelete (or the execute variants) are called with a blank/null databaseName or schemaName in the request payload.
Common situations: Frontend sends an empty name field; path/query param not bound; client-side validation skipped before the request.
Related errors
- database.delete.invalidDataSource
- database.delete.notSupportDbType
- database.delete.prepareFailed
- database.delete.connectionTargetsDeletedDatabase
- database.delete.executeFailed
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/a64bb8f28e96e87d.
Report an issue: GitHub.