iflytek/astron-agent · error · BusinessException
DATABASE_TABLE_FIELD_CANNOT_EMPTY
DATABASE_TABLE_FIELD_CANNOT_EMPTY
Error message
DATABASE_TABLE_FIELD_CANNOT_EMPTY
What it means
Thrown by DatabaseService.createDbTable when the DbTableDto submitted for table creation has a null or empty fields list. The platform requires at least one user-defined column to build the DDL for the physical table; a table with no fields cannot be materialized in the core database system.
Solutions
- Add at least one field object to the 'fields' array in the create-table request payload
- If calling via UI, add columns in the table creation form before submitting
- Verify the JSON key is exactly 'fields' and is a non-empty array in the request body
Example fix
// before
POST /database/table
{"dbId": 1, "name": "users", "fields": []}
// after
POST /database/table
{"dbId": 1, "name": "users", "fields": [{"name": "username", "type": "VARCHAR"}]} Defensive patterns
Strategy: validation
Validate before calling
if (dto.getFields() == null || dto.getFields().isEmpty()) {
throw new IllegalArgumentException("fields must contain at least one column");
} Type guard
boolean hasFields(DbTableDto dto) {
return dto.getFields() != null && !dto.getFields().isEmpty();
} Try / catch
try {
databaseService.createDbTable(dto);
} catch (BusinessException e) {
if ("DATABASE_TABLE_FIELD_CANNOT_EMPTY".equals(e.getCode())) { /* prompt user to add fields */ }
throw e;
} Prevention
- Validate the fields array client-side before submitting the create-table form
- Use a request-schema validator (e.g. @NotEmpty on the DTO list) for early rejection
- Check API payload key spelling ('fields') when scripting requests
When it happens
Trigger: Calling POST table creation (createDbTable) with a request body where 'fields' is absent, null, or an empty array []. Note the outer catch (Exception) at line 336 wraps any exception into DATABASE_TABLE_CREATE_FAILED, but this specific check at line 296-297 throws DATABASE_TABLE_FIELD_CANNOT_EMPTY before DDL execution.
Common situations: Frontend form submitted without adding any columns; API consumers scripting table creation omit the fields array; a DTO deserialization drops fields because the JSON key is misspelled (e.g. 'field' instead of 'fields').
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- DATABASE_FIELD_CANNOT_BEYOND_20
- DATABASE_ID_CANNOT_EMPTY
- DATABASE_NOT_EXIST
- DATABASE_TABLE_NAME_EXIST
- 20201
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/82f4c62482fc5a1c.
Report an issue: GitHub.
Appendix: source
Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:297
}
// Table count limit
Long tableCount = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
.eq(DbTable::getDbId, dbInfo.getDbId())
.eq(DbTable::getDeleted, false));
if (tableCount > 20) {
throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED);
}
// Duplicate table name validation
Long count = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()
.eq(DbTable::getName, dbTableDto.getName())
.eq(DbTable::getDbId, dbInfo.getDbId())
.eq(DbTable::getDeleted, false));
if (count > 0) {
throw new BusinessException(ResponseEnum.DATABASE_TABLE_NAME_EXIST);
}
// Build DDL statement and validate required system fields
if (dbTableDto.getFields() == null || dbTableDto.getFields().isEmpty()) {
throw new BusinessException(ResponseEnum.DATABASE_TABLE_FIELD_CANNOT_EMPTY);
}
// Table fields cannot exceed 20
if (dbTableDto.getFields().size() > 20) {
throw new BusinessException(ResponseEnum.DATABASE_FIELD_CANNOT_BEYOND_20);
}
// Save information
DbTable dbTable = new DbTable();
BeanUtils.copyProperties(dbTableDto, dbTable);
dbTable.setCreateTime(new Date());
dbTable.setUpdateTime(new Date());
dbTableMapper.insert(dbTable);
List<String> systemFields = Arrays.asList(SYSTEM_FIELDS);
List<DbTableField> fields = new ArrayList<>();
for (DbTableFieldDto field : dbTableDto.getFields()) {
DbTableField dbTableField = new DbTableField();
BeanUtils.copyProperties(field, dbTableField);
if (systemFields.contains(field.getName())) {
dbTableField.setIsSystem(true);View on GitHub (pinned to 5e758547a8)