{"record":{"id":"66b8b17a0fa02464","repo":"jeecgboot/JeecgBoot","slug":"tablename-tablename","errorCode":null,"errorMessage":"[白名单] 表名已存在，但是已被禁用，请先启用！tableName={tableName}","messagePattern":"\\[白名单\\] 表名已存在，但是已被禁用，请先启用！tableName=(.+?)","errorType":"exception","errorClass":"JeecgBootException","httpStatus":null,"severity":"warning","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java","lineNumber":111,"sourceCode":"    @Override\n    public SysTableWhiteList autoAdd(String tableName, String fieldName) {\n        if (oConvertUtils.isEmpty(tableName)) {\n            throw new JeecgBootException(\"操作失败，表名不能为空！\");\n        }\n        if (oConvertUtils.isEmpty(fieldName)) {\n            throw new JeecgBootException(\"操作失败，字段名不能为空！\");\n        }\n        // 统一转换成小写\n        tableName = tableName.toLowerCase();\n        fieldName = fieldName.toLowerCase();\n        // 查询是否已经存在\n        LambdaQueryWrapper<SysTableWhiteList> queryWrapper = new LambdaQueryWrapper<>();\n        queryWrapper.eq(SysTableWhiteList::getTableName, tableName);\n        SysTableWhiteList getEntity = super.getOne(queryWrapper);\n        if (getEntity != null) {\n            // 如果已经存在，并且已禁用，则抛出异常\n            if (CommonConstant.STATUS_0.equals(getEntity.getStatus())) {\n                throw new JeecgBootException(\"[白名单] 表名已存在，但是已被禁用，请先启用！tableName=\" + tableName);\n            }\n            // 合并字段\n            Set<String> oldFieldSet = new HashSet<>(Arrays.asList(getEntity.getFieldName().split(\",\")));\n            Set<String> newFieldSet = new HashSet<>(Arrays.asList(fieldName.split(\",\")));\n            oldFieldSet.addAll(newFieldSet);\n            getEntity.setFieldName(String.join(\",\", oldFieldSet));\n            this.checkEntity(getEntity);\n            super.updateById(getEntity);\n            log.info(\"修改表单白名单项，表名：{}，oldFieldSet： {}，newFieldSet：{}\", tableName, oldFieldSet.toArray(), newFieldSet.toArray());\n            return getEntity;\n        } else {\n            // 新增白名单项\n            SysTableWhiteList saveEntity = new SysTableWhiteList();\n            saveEntity.setTableName(tableName);\n            saveEntity.setFieldName(fieldName);\n            saveEntity.setStatus(CommonConstant.STATUS_1);\n            this.checkEntity(saveEntity);\n            super.save(saveEntity);","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysTableWhiteListServiceImpl.java#L93-L129","documentation":"Thrown by autoAdd when a SysTableWhiteList row for the given (lower-cased) tableName already exists but its status equals CommonConstant.STATUS_0 (disabled). The system refuses to silently merge fields into a disabled entry because the operator must consciously re-enable it. The error message appends the offending tableName for traceability.","triggerScenarios":"autoAdd is called for a table that was previously whitelisted then disabled (status set to 0) by an admin, and a new form/field registration now tries to add to it. The lookup queryWrapper.eq(tableName) returns the disabled row, triggering the branch.","commonSituations":"A table was decommissioned and its whitelist entry disabled, but a lingering online form or scheduled sync still calls autoAdd; re-importing an old form after a table rename/disable cycle; manual DB status edit left a row disabled.","solutions":["Open the whitelist management page (system menu), find the entry for the tableName shown in the error, and set its status to enabled.","Programmatically enable it first: load the entity, setStatus(STATUS_1), updateById, then call autoAdd.","If the disabled entry is stale, delete it so autoAdd creates a fresh enabled record.","Audit who/what disabled the entry (check update_by / update_time on the row) to prevent recurrence."],"exampleFix":"// before\nwhiteListService.autoAdd(tableName, fieldName);\n\n// after\nSysTableWhiteList existing = whiteListService.getOne(\n    new LambdaQueryWrapper<SysTableWhiteList>()\n        .eq(SysTableWhiteList::getTableName, tableName.toLowerCase()));\nif (existing != null && CommonConstant.STATUS_0.equals(existing.getStatus())) {\n    existing.setStatus(CommonConstant.STATUS_1);\n    whiteListService.updateById(existing);\n}\nwhiteListService.autoAdd(tableName, fieldName);","handlingStrategy":"try-catch","validationCode":"SysTableWhiteList ex = whiteListService.getOne(new LambdaQueryWrapper<SysTableWhiteList>()\n    .eq(SysTableWhiteList::getTableName, tableName.toLowerCase()));\nif (ex != null && CommonConstant.STATUS_0.equals(ex.getStatus())) {\n    ex.setStatus(CommonConstant.STATUS_1);\n    whiteListService.updateById(ex);\n}","typeGuard":null,"tryCatchPattern":"try {\n    whiteListService.autoAdd(tableName, fieldName);\n} catch (JeecgBootException e) {\n    if (e.getMessage().contains(\"已被禁用\")) {\n        // prompt user to enable, or auto-enable then retry once\n    }\n    throw e;\n}","preventionTips":["Before autoAdd, check for an existing disabled entry and enable it or prompt the user.","Avoid leaving whitelist entries in disabled state when the underlying table is still in use.","Audit disabled whitelist entries periodically."],"tags":["whitelist","state-conflict","jeecg-boot","business-rule"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}