{"record":{"id":"db7cb397c71392bb","repo":"paascloud/paascloud-master","slug":"uac10011001-db7cb3","errorCode":"UAC10011001","errorMessage":"ErrorCodeEnum.UAC10011001","messagePattern":"ErrorCodeEnum\\.UAC10011001","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":336,"sourceCode":"\t\tList<UacRoleUser> uruList = uacRoleUserService.listByRoleIdList(roleIdList);\n\t\tif (!uruList.isEmpty()) {\n\t\t\tuacRoleUserService.deleteByRoleIdList(roleIdList);\n\t\t}\n\n\t\tuacRoleMenuService.deleteByRoleIdList(roleIdList);\n\t\tuacRoleActionService.deleteByRoleIdList(roleIdList);\n\n\t\tint result = uacRoleMapper.batchDeleteByIdList(roleIdList);\n\t\tif (result < roleIdList.size()) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012006, Joiner.on(GlobalConstant.Symbol.COMMA).join(roleIdList));\n\t\t}\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic List<MenuVo> getOwnAuthTree(Long userId) {\n\t\tif (userId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011001);\n\t\t}\n\n\t\treturn uacMenuService.getMenuVoList(userId, GlobalConstant.Sys.OPER_APPLICATION_ID);\n\t}\n\n\t@Override\n\tpublic void bindMenu(RoleBindMenuDto roleBindMenuDto) {\n\n\t\tLong roleId = roleBindMenuDto.getRoleId();\n\t\tSet<Long> menuIdList = roleBindMenuDto.getMenuIdList();\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);","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java#L318-L354","documentation":"UAC10011001 is thrown when the userId argument passed to getOwnAuthTree is null. The UAC (User Authentication Center) role service requires a concrete user id to build the list of MenuVo entries the user is authorized for; without it no menu query can be performed. This is a fail-fast argument validation before delegating to uacMenuService.getMenuVoList.","triggerScenarios":"Calling UacRoleService.getOwnAuthTree(null), typically when the caller's session user id was never populated (unauthenticated request, missing login user context, or a DTO field that was never set).","commonSituations":"Developers hit this when the current-user lookup (e.g. from security context or request header) silently returns null, when integrating the API without authentication, or when copying service code and forgetting to resolve the userId from the logged-in principal.","solutions":["Ensure the userId is resolved from the authenticated session/principal before calling getOwnAuthTree","Validate/Preconditions.checkNotNull the userId at the controller or caller layer","Check that the login user context (e.g. WrappedUser / request header) is populated; fix authentication if it is null","If null legitimately means 'no user', return an empty list or an auth error instead of passing null through"],"exampleFix":"// before\nLong userId = getLoginUserId(); // may return null\nList<MenuVo> menus = uacRoleService.getOwnAuthTree(userId);\n// after\nLong userId = getLoginUserId();\nPreconditions.checkNotNull(userId, \"login userId must not be null\");\nList<MenuVo> menus = uacRoleService.getOwnAuthTree(userId);","handlingStrategy":"validation","validationCode":"if (userId == null) { throw new IllegalArgumentException(\"userId must not be null\"); }","typeGuard":"boolean userIdPresent(Long userId) { return userId != null && userId > 0; }","tryCatchPattern":"try { return uacRoleService.getOwnAuthTree(userId); } catch (UacBizException e) { if (\"UAC10011001\".equals(e.getCode())) { throw new BadRequestException(\"userId is required\"); } throw e; }","preventionTips":["Always derive userId from the authenticated principal, never from client-supplied nullable fields","Null-check user context at the controller/filter layer before entering services","Use Preconditions.checkNotNull for required arguments in service callers","Add unit tests covering null userId for menu-authorization endpoints"],"tags":["null-argument","java","uac","role-service"],"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"}