{"record":{"id":"a6915dc3607daee0","repo":"paascloud/paascloud-master","slug":"uac10012001-a6915d","errorCode":"UAC10012001","errorMessage":"角色ID不能为空","messagePattern":"角色ID不能为空","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java","lineNumber":73,"sourceCode":"\tprivate UacRoleActionService uacRoleActionService;\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic UacRole findByRoleCode(String roleCode) {\n\t\treturn uacRoleMapper.findByRoleCode(roleCode);\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic List<RoleVo> queryRoleListWithPage(UacRole role) {\n\t\treturn uacRoleMapper.queryRoleListWithPage(role);\n\t}\n\n\t@Override\n\tpublic int deleteRoleById(Long roleId) {\n\t\t//查询该角色下是否有用户绑定, 有的话提醒不能删除\n\t\tif (null == roleId) {\n\t\t\tthrow new IllegalArgumentException(ErrorCodeEnum.UAC10012001.msg());\n\t\t}\n\n\t\t// 超级管理员不能删除\n\t\tif (Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID)) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012003);\n\t\t}\n\n\t\tList<UacRoleUser> uruList = uacRoleUserService.listByRoleId(roleId);\n\n\t\tif (!uruList.isEmpty()) {\n\t\t\tuacRoleUserService.deleteByRoleId(roleId);\n\t\t}\n\n\t\tuacRoleActionService.deleteByRoleId(roleId);\n\t\tuacRoleMenuService.deleteByRoleId(roleId);\n\t\treturn uacRoleMapper.deleteByPrimaryKey(roleId);\n\t}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java#L55-L91","documentation":"IllegalArgumentException carrying message of UAC10012001 ('角色ID不能为空') thrown by UacRoleServiceImpl.deleteRoleById when roleId is null. Unlike the other errors in this family, a plain IllegalArgumentException is used; the null ID cannot identify a role to delete.","triggerScenarios":"Calling uacRoleService.deleteRoleById(null), e.g. a delete request whose id parameter was missing or failed binding.","commonSituations":"Delete button rendered without a role context; REST path variable omitted; stale UI state after the role was deleted by another user.","solutions":["Pass a valid roleId from the selected row","Validate the id request parameter before calling the service","Handle IllegalArgumentException in the controller and return a 'role id required' response"],"exampleFix":"// before\nuacRoleService.deleteRoleById(request.getParameter(\"roleId\") == null ? null : Long.valueOf(request.getParameter(\"roleId\")));\n// after\nLong roleId = Long.valueOf(request.getParameter(\"roleId\"));\nuacRoleService.deleteRoleById(roleId);","handlingStrategy":"validation","validationCode":"if (roleId == null) {\n    return Result.error(\"roleId is required\");\n}","typeGuard":"boolean isDeletable(Long roleId) { return roleId != null && roleId > 0 && !Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID); }","tryCatchPattern":"try {\n    uacRoleService.deleteRoleById(roleId);\n} catch (IllegalArgumentException e) {\n    return Result.error(\"角色ID不能为空\");\n}","preventionTips":["Validate the id parameter in the controller before service calls","Disable delete buttons when no role row is selected","Clean stale UI state after role deletions"],"tags":["java","null-check","illegal-argument","uac"],"backgroundTag":"null-argument","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}