{"record":{"id":"b9f193c826cdc483","repo":"paascloud/paascloud-master","slug":"uac10012005","errorCode":"UAC10012005","errorMessage":"找不到角色信息,roleId=%s","messagePattern":"找不到角色信息,roleId=(.+?)","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java","lineNumber":136,"sourceCode":"\t@Override\n\tpublic void bindAction(RoleBindActionDto grantAuthRole) {\n\t\tLong roleId = grantAuthRole.getRoleId();\n\t\tSet<Long> actionIdList = grantAuthRole.getActionIdList();\n\n\t\tif (roleId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012001);\n\t\t}\n\n\t\tif (Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID)) {\n\t\t\tlogger.error(\"越权操作, 超级管理员用户不允许操作\");\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011023);\n\t\t}\n\n\t\tUacRole uacRole = uacRoleMapper.selectByPrimaryKey(roleId);\n\n\t\tif (uacRole == null) {\n\t\t\tlogger.error(\"找不到角色信息. roleId={}\", roleId);\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012005, roleId);\n\t\t}\n\n\t\t// TODO 校验参数的合法性(这里不写了 累得慌 也就是校验菜单和权限是否存在)\n\t\tList<UacRoleAction> uacRoleActionList = uacRoleActionService.listByRoleId(roleId);\n\n\t\tif (PublicUtil.isNotEmpty(uacRoleActionList)) {\n\t\t\tuacRoleActionService.deleteByRoleId(roleId);\n\t\t}\n\n\t\tif (PublicUtil.isEmpty(actionIdList)) {\n\t\t\tlogger.error(\"传入按钮权限Id为空, 取消所有按钮权限\");\n\t\t} else {\n\t\t\t// 绑定权限\n\t\t\tuacRoleActionService.insert(roleId, actionIdList);\n\t\t}\n\t}\n\n\t@Override","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java#L118-L154","documentation":"UacBizException UAC10012005 ('找不到角色信息,roleId=%s') thrown by UacRoleServiceImpl.bindAction when uacRoleMapper.selectByPrimaryKey(roleId) returns null. The roleId passed the null check but no role row exists with that ID, formatted with the offending roleId.","triggerScenarios":"bindAction called with a roleId that does not exist in the uac_role table — deleted role, wrong database/environment, or fabricated ID in the request.","commonSituations":"Client caching a role list while another admin deleted the role; multi-environment deployment using IDs from another DB; typos in hardcoded IDs in scripts or tests.","solutions":["Verify the roleId exists (select from uac_role) in the target environment before binding","Refresh the client's role list after deletes","Confirm the service is pointed at the intended database/datasource"],"exampleFix":"// before\nuacRoleService.bindAction(dto); // throws if role was deleted\n// after\nUacRole role = uacRoleMapper.selectByPrimaryKey(dto.getRoleId());\nif (role != null) {\n    uacRoleService.bindAction(dto);\n} else {\n    throw new BusinessException(\"role \" + dto.getRoleId() + \" no longer exists\");\n}","handlingStrategy":"try-catch","validationCode":"UacRole role = uacRoleMapper.selectByPrimaryKey(roleId);\nif (role == null) {\n    return Result.error(\"角色不存在: \" + roleId);\n}","typeGuard":"boolean roleExists(UacRoleMapper mapper, Long roleId) { return roleId != null && mapper.selectByPrimaryKey(roleId) != null; }","tryCatchPattern":"try {\n    uacRoleService.bindAction(dto);\n} catch (UacBizException e) {\n    if (ErrorCodeEnum.UAC10012005.getCode().equals(e.getCode())) {\n        return Result.error(\"角色不存在，请刷新角色列表\");\n    }\n    throw e;\n}","preventionTips":["Refresh role caches/lists after deletes","Verify environment-specific role IDs before scripted calls","Validate foreign-key references before cross-service writes","Confirm the datasource points at the intended environment"],"tags":["java","not-found","uac","database"],"backgroundTag":"record-not-found","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"}