{"record":{"id":"73fa55e1fcbf2e0e","repo":"iflytek/astron-agent","slug":"database-cannot-empty","errorCode":"DATABASE_CANNOT_EMPTY","errorMessage":"DATABASE_CANNOT_EMPTY","messagePattern":"DATABASE_CANNOT_EMPTY","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DBTableExcelReadListener.java","lineNumber":74,"sourceCode":"        if (!expectedHeadersFormat.equals(actualHeaders)) {\n            throw new BusinessException(ResponseEnum.DATABASE_TABLE_FIELD_IMPORT_DEFAULT);\n        }\n    }\n\n    /**\n     * Parse and validate each row, then convert to {@link DbTableFieldDto}.\n     *\n     * @param row the row data, key is column index, value is cell content\n     * @param context analysis context\n     * @throws BusinessException if required fields are empty, type is illegal, or default value is\n     *         invalid\n     */\n    @Override\n    public void invoke(Map<Integer, String> row, AnalysisContext context) {\n        // Validate required fields are not empty\n        DbTableFieldDto dbTableFieldDto = new DbTableFieldDto();\n        if (row.get(0) == null || row.get(1) == null || row.get(2) == null || row.get(4) == null) {\n            throw new BusinessException(ResponseEnum.DATABASE_CANNOT_EMPTY);\n        }\n        dbTableFieldDto.setName(row.get(0));\n        if (!fieldType.contains(row.get(1))) {\n            throw new BusinessException(ResponseEnum.DATABASE_TYPE_ILLEGAL);\n        }\n        dbTableFieldDto.setType(row.get(1));\n        dbTableFieldDto.setDescription(row.get(2));\n        if (StringUtils.isNotBlank(row.get(3))) {\n            if (\"Integer\".equalsIgnoreCase(row.get(1))) {\n                try {\n                    Long.parseLong(row.get(3));\n                } catch (NumberFormatException e) {\n                    throw new BusinessException(ResponseEnum.DATABASE_TABLE_ILLEGAL_DEFAULT);\n                }\n            } else if (\"Boolean\".equalsIgnoreCase(row.get(1))) {\n                if (!\"true\".equalsIgnoreCase(row.get(3)) && !\"false\".equalsIgnoreCase(row.get(3))) {\n                    throw new BusinessException(ResponseEnum.DATABASE_TABLE_ILLEGAL_DEFAULT);\n                }","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DBTableExcelReadListener.java#L56-L92","documentation":"DBTableExcelReadListener.invoke throws BusinessException(DATABASE_CANNOT_EMPTY) when any of the required columns in a data row is null: column 0 (字段名/Field Name), 1 (数据类型/Data Type), 2 (描述/Description), or 4 (是否必填/Required). These four fields are mandatory for each table-field definition row; the Default Value column (3) is the only optional one.","triggerScenarios":"A data row has an empty cell in columns A, B, C, or E (0-indexed 0,1,2,4); the row exists in Excel but EasyExcel delivers null for truly blank cells; the user left Required blank instead of filling 是/否.","commonSituations":"Users skip the Description column thinking it optional; leaving the Required column empty; rows with trailing blank cells; partially filled template rows.","solutions":["Fill in every required column of the row: Field Name, Data Type, Description, and Required (是/否) — Default Value may stay empty.","Remove completely blank rows that Excel may still deliver to the parser.","For Required, explicitly enter 是 or 否 rather than leaving it blank."],"exampleFix":"// before\n// age | Integer | (empty desc) | | 是   -> DATABASE_CANNOT_EMPTY\n// after\n// age | Integer | user age | 0 | 是","handlingStrategy":"validation","validationCode":"// pre-flight: required columns 0,1,2,4 must be non-null on every row\nboolean rowComplete = row.get(0) != null && row.get(1) != null\n        && row.get(2) != null && row.get(4) != null;\nif (!rowComplete) throw new IllegalArgumentException(\"Field Name, Data Type, Description and Required are mandatory\");","typeGuard":null,"tryCatchPattern":"try {\n    EasyExcel.read(file, listener).sheet().doRead();\n} catch (BusinessException e) {\n    if (\"DATABASE_CANNOT_EMPTY\".equals(e.getCode())) {\n        // report the first row with a missing required cell to the user\n    }\n}","preventionTips":["Fill all four required columns on every row; only Default Value is optional.","Delete fully blank rows below the data before saving the file.","Enter 是 or 否 explicitly in the Required column."],"tags":["excel","validation","required-field","java"],"backgroundTag":"empty-required-field","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}