iflytek/astron-agent · error · BusinessException

DATABASE_FIELD_CANNOT_BEYOND_20

DATABASE_FIELD_CANNOT_BEYOND_20

Error message

DATABASE_FIELD_CANNOT_BEYOND_20

What it means

Thrown by DatabaseService.createDbTable when the submitted DbTableDto contains more than 20 fields. The platform caps table columns at 20 to keep DDL and table management manageable; the count includes all fields in the request.

Solutions

  1. Reduce the fields array to 20 or fewer columns before submitting
  2. Split the data model into multiple tables of <=20 columns each
  3. If truly wide data is needed, store overflow columns as a JSON/text column

Example fix

// before
fields: [c1, c2, ..., c25]  // 25 columns
// after
fields: fields.subList(0, 20)  // or redesign into two tables
Defensive patterns

Strategy: validation

Validate before calling

if (dto.getFields() != null && dto.getFields().size() > 20) {
    throw new IllegalArgumentException("at most 20 fields allowed, got " + dto.getFields().size());
}

Type guard

boolean withinFieldLimit(DbTableDto dto) {
    return dto.getFields() == null || dto.getFields().size() <= 20;
}

Try / catch

try {
    databaseService.createDbTable(dto);
} catch (BusinessException e) {
    if ("DATABASE_FIELD_CANNOT_BEYOND_20".equals(e.getCode())) { /* truncate or split schema */ }
    throw e;
}

Prevention

When it happens

Trigger: Calling createDbTable with fields.size() > 20, i.e. more than 20 column entries in the 'fields' array of the create-table request.

Common situations: Migrating a wide existing table into the platform; bulk-generating columns programmatically; importing a CSV schema with many headers without truncating.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/adac93b82b93705e. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java:301

                    .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);
                } else {
                    if (StringUtils.isBlank(dbTableField.getDefaultValue())) {
                        dbTableField.setDefaultValue(transFormDefaultValue(field.getType()).toString());
                        field.setDefaultValue(transFormDefaultValue(field.getType()).toString());

View on GitHub (pinned to 5e758547a8)