{"record":{"id":"adac93b82b93705e","repo":"iflytek/astron-agent","slug":"database-field-cannot-beyond-20","errorCode":"DATABASE_FIELD_CANNOT_BEYOND_20","errorMessage":"DATABASE_FIELD_CANNOT_BEYOND_20","messagePattern":"DATABASE_FIELD_CANNOT_BEYOND_20","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java","lineNumber":301,"sourceCode":"                    .eq(DbTable::getDeleted, false));\n            if (tableCount > 20) {\n                throw new BusinessException(ResponseEnum.DATABASE_COUNT_LIMITED);\n            }\n            // Duplicate table name validation\n            Long count = dbTableMapper.selectCount(new QueryWrapper<DbTable>().lambda()\n                    .eq(DbTable::getName, dbTableDto.getName())\n                    .eq(DbTable::getDbId, dbInfo.getDbId())\n                    .eq(DbTable::getDeleted, false));\n            if (count > 0) {\n                throw new BusinessException(ResponseEnum.DATABASE_TABLE_NAME_EXIST);\n            }\n            // Build DDL statement and validate required system fields\n            if (dbTableDto.getFields() == null || dbTableDto.getFields().isEmpty()) {\n                throw new BusinessException(ResponseEnum.DATABASE_TABLE_FIELD_CANNOT_EMPTY);\n            }\n            // Table fields cannot exceed 20\n            if (dbTableDto.getFields().size() > 20) {\n                throw new BusinessException(ResponseEnum.DATABASE_FIELD_CANNOT_BEYOND_20);\n            }\n            // Save information\n            DbTable dbTable = new DbTable();\n            BeanUtils.copyProperties(dbTableDto, dbTable);\n            dbTable.setCreateTime(new Date());\n            dbTable.setUpdateTime(new Date());\n            dbTableMapper.insert(dbTable);\n            List<String> systemFields = Arrays.asList(SYSTEM_FIELDS);\n            List<DbTableField> fields = new ArrayList<>();\n            for (DbTableFieldDto field : dbTableDto.getFields()) {\n                DbTableField dbTableField = new DbTableField();\n                BeanUtils.copyProperties(field, dbTableField);\n                if (systemFields.contains(field.getName())) {\n                    dbTableField.setIsSystem(true);\n                } else {\n                    if (StringUtils.isBlank(dbTableField.getDefaultValue())) {\n                        dbTableField.setDefaultValue(transFormDefaultValue(field.getType()).toString());\n                        field.setDefaultValue(transFormDefaultValue(field.getType()).toString());","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DatabaseService.java#L283-L319","documentation":"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.","triggerScenarios":"Calling createDbTable with fields.size() > 20, i.e. more than 20 column entries in the 'fields' array of the create-table request.","commonSituations":"Migrating a wide existing table into the platform; bulk-generating columns programmatically; importing a CSV schema with many headers without truncating.","solutions":["Reduce the fields array to 20 or fewer columns before submitting","Split the data model into multiple tables of <=20 columns each","If truly wide data is needed, store overflow columns as a JSON/text column"],"exampleFix":"// before\nfields: [c1, c2, ..., c25]  // 25 columns\n// after\nfields: fields.subList(0, 20)  // or redesign into two tables","handlingStrategy":"validation","validationCode":"if (dto.getFields() != null && dto.getFields().size() > 20) {\n    throw new IllegalArgumentException(\"at most 20 fields allowed, got \" + dto.getFields().size());\n}","typeGuard":"boolean withinFieldLimit(DbTableDto dto) {\n    return dto.getFields() == null || dto.getFields().size() <= 20;\n}","tryCatchPattern":"try {\n    databaseService.createDbTable(dto);\n} catch (BusinessException e) {\n    if (\"DATABASE_FIELD_CANNOT_BEYOND_20\".equals(e.getCode())) { /* truncate or split schema */ }\n    throw e;\n}","preventionTips":["Enforce the 20-field cap in the UI form (limit added columns)","Design schemas with <=20 columns from the start","When importing schemas, truncate or normalize to the cap"],"tags":["validation","database","limit"],"backgroundTag":"value-out-of-range","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}