{"record":{"id":"87e569aab1c245c1","repo":"paascloud/paascloud-master","slug":"uac10012006-87e569","errorCode":"UAC10012006","errorMessage":"ErrorCodeEnum.UAC10012006","messagePattern":"ErrorCodeEnum\\.UAC10012006","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleUserServiceImpl.java","lineNumber":147,"sourceCode":"\n\t@Override\n\tpublic void deleteByRoleIdList(List<Long> roleIdList) {\n\t\tPreconditions.checkArgument(PublicUtil.isNotEmpty(roleIdList), ErrorCodeEnum.UAC10012001.msg());\n\t\tPreconditions.checkArgument(!roleIdList.contains(GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID), \"超级管理员角色不能删除\");\n\t\tint result = uacRoleUserMapper.deleteByRoleIdList(roleIdList);\n\t\tif (result < roleIdList.size()) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012007, Joiner.on(GlobalConstant.Symbol.COMMA).join(roleIdList));\n\t\t}\n\t}\n\n\t@Override\n\tpublic void deleteByRoleId(Long roleId) {\n\t\tPreconditions.checkArgument(roleId != null, ErrorCodeEnum.UAC10012001.msg());\n\t\tPreconditions.checkArgument(!Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID), \"超级管理员角色不能删除\");\n\n\t\tint result = uacRoleUserMapper.deleteByRoleId(roleId);\n\t\tif (result < 1) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012006, roleId);\n\t\t}\n\t}\n}\n","sourceCodeStart":129,"sourceCodeEnd":151,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleUserServiceImpl.java#L129-L151","documentation":"UacBizException with code UAC10012006 (role-user delete by roleId failed) thrown by deleteByRoleId when the delete statement affects zero rows. The service expects at least one role-user binding to be removed for the given roleId.","triggerScenarios":"deleteByRoleId(roleId) where the role has no assigned users — the mapper's deleteByRoleId returns 0 and the service raises the exception with the roleId in the message.","commonSituations":"Deleting bindings for a role that never had users; the bindings were already deleted by a prior request or another admin; roleId typo pointing to a different role.","solutions":["Check that the role actually has user bindings before calling deleteByRoleId (query listByRoleId first).","Treat deletion of an empty role as a no-op: skip the call when listByRoleId(roleId) is empty.","Confirm the roleId is correct; inspect the message's roleId against the database."],"exampleFix":"// before\nuacRoleUserService.deleteByRoleId(roleId);\n// after\nif (PublicUtil.isNotEmpty(uacRoleUserService.listByRoleId(roleId))) {\n    uacRoleUserService.deleteByRoleId(roleId);\n}","handlingStrategy":"try-catch","validationCode":"if (PublicUtil.isEmpty(uacRoleUserService.listByRoleId(roleId))) { return; }\nuacRoleUserService.deleteByRoleId(roleId);","typeGuard":"boolean deletable = roleId != null && !Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID);","tryCatchPattern":"try {\n    uacRoleUserService.deleteByRoleId(roleId);\n} catch (UacBizException e) {\n    if (\"UAC10012006\".equals(e.getCode())) { log.info(\"no bindings for roleId {}\", roleId); return; }\n    throw e;\n}","preventionTips":["Skip deletion when the role has no bindings","Make deletes idempotent — treat zero rows as success","Verify roleId correctness before invoking delete"],"tags":["database","role-management","delete-failed"],"backgroundTag":"database-write-failed","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"}