{"record":{"id":"74625f0dd6595fc4","repo":"iflytek/astron-agent","slug":"database-type-illegal","errorCode":"DATABASE_TYPE_ILLEGAL","errorMessage":"DATABASE_TYPE_ILLEGAL","messagePattern":"DATABASE_TYPE_ILLEGAL","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":78,"sourceCode":"\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                }\n            } else if (\"Number\".equalsIgnoreCase(row.get(1))) {\n                try {\n                    Double.parseDouble(row.get(3));\n                } catch (NumberFormatException e) {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/toolkit/src/main/java/com/iflytek/astron/console/toolkit/service/database/DBTableExcelReadListener.java#L60-L96","documentation":"DBTableExcelReadListener.invoke throws BusinessException(DATABASE_TYPE_ILLEGAL) when the Data Type column (index 1) contains a value not in the allowed set: String, Integer, Time, Number, Boolean. The check is exact case-sensitive contains() on the raw cell string, so \"integer\", \"INT\", or \"Long\" all fail even though Integer comparison elsewhere uses equalsIgnoreCase.","triggerScenarios":"A row's Data Type cell contains an unsupported type like \"Text\", \"Long\", \"Decimal\", \"int\", \"datetime\", or a lowercase/typo variant such as \"integer\" or \"string\" (case-sensitive check); cell has trailing whitespace making it not exactly match.","commonSituations":"Users familiar with SQL write native types (VARCHAR, INT, DATETIME); autocorrect capitalization in Excel; trailing spaces from copy-paste.","solutions":["Set the Data Type cell to exactly one of: String, Integer, Time, Number, Boolean (capitalized as shown).","Replace SQL-native type names (INT, VARCHAR, DECIMAL) with the closest supported type.","Trim whitespace from the Data Type cell (e.g., \"Integer \" fails the exact match)."],"exampleFix":"// before\n// age | int | user age | | 是 -> DATABASE_TYPE_ILLEGAL\n// after\n// age | Integer | user age | | 是","handlingStrategy":"validation","validationCode":"// pre-flight: Data Type must be exactly one of the supported values\nList<String> allowed = List.of(\"String\", \"Integer\", \"Time\", \"Number\", \"Boolean\");\nString t = row.get(1) == null ? \"\" : row.get(1).trim();\nif (!allowed.contains(t)) throw new IllegalArgumentException(\"Unsupported data type: \" + row.get(1));","typeGuard":null,"tryCatchPattern":"try {\n    EasyExcel.read(file, listener).sheet().doRead();\n} catch (BusinessException e) {\n    if (\"DATABASE_TYPE_ILLEGAL\".equals(e.getCode())) {\n        // show the allowed type list to the user\n    }\n}","preventionTips":["Pick types only from the template dropdown: String, Integer, Time, Number, Boolean.","Map SQL-native types (INT, VARCHAR, DATETIME) to the closest supported type.","Trim the cell and use exact capitalization (\"integer\" fails)."],"tags":["excel","validation","enum","java"],"backgroundTag":"invalid-enum-value","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"}