{"record":{"id":"72dd99490b9d13c4","repo":"paascloud/paascloud-master","slug":"uac10012001-72dd99","errorCode":"UAC10012001","errorMessage":"ErrorCodeEnum.UAC10012001","messagePattern":"ErrorCodeEnum\\.UAC10012001","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":61,"sourceCode":"\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic List<UacRoleUser> queryByUserId(Long userId) {\n\t\tif (null == userId) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011001);\n\t\t}\n\n\t\treturn uacRoleUserMapper.listByUserId(userId);\n\t}\n\n\t@Override\n\t@Transactional(readOnly = true, rollbackFor = Exception.class)\n\tpublic UacRoleUser getByUserIdAndRoleId(Long userId, Long roleId) {\n\n\t\tif (null == userId) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011001);\n\t\t}\n\n\t\tif (null == roleId) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012001);\n\t\t}\n\n\t\treturn uacRoleUserMapper.getByUserIdAndRoleId(userId, roleId);\n\t}\n\n\t@Override\n\tpublic int saveRoleUser(Long userId, Long roleId) {\n\t\tif (userId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011001);\n\t\t}\n\t\tif (roleId == null) {\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10012001);\n\t\t}\n\n\t\tUacRoleUser roleUser = new UacRoleUser();\n\t\troleUser.setUserId(userId);\n\t\troleUser.setRoleId(roleId);\n\t\treturn uacRoleUserMapper.insertSelective(roleUser);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleUserServiceImpl.java#L43-L79","documentation":"UAC10012001 is thrown by UacRoleUserServiceImpl.getByUserIdAndRoleId when the roleId parameter is null. After confirming userId is non-null (UAC10011001), the method validates roleId and fails fast before calling uacRoleUserMapper.getByUserIdAndRoleId(userId, roleId).","triggerScenarios":"Calling getByUserIdAndRoleId(userId, null) — the role selection was not sent or the DTO field was never set when checking/creating a user-role binding.","commonSituations":"UIs that allow submitting a role-assignment form without picking a role, API calls omitting roleId, or programmatic DTO construction missing setRoleId.","solutions":["Set/validate roleId before calling getByUserIdAndRoleId","Enforce @NotNull on roleId in the request DTO/controller validation","In the UI, disable submit until a role is selected","Catch UacBizException UAC10012001 and prompt the user to select a role"],"exampleFix":"// before\nif (request.getRoleId() != null) {\n    uacRoleUserService.getByUserIdAndRoleId(request.getUserId(), request.getRoleId());\n}\n// after\nPreconditions.checkNotNull(request.getRoleId(), \"roleId required\");\nuacRoleUserService.getByUserIdAndRoleId(request.getUserId(), request.getRoleId());","handlingStrategy":"validation","validationCode":"if (roleId == null) { throw new IllegalArgumentException(\"roleId is required\"); }","typeGuard":"boolean validRoleId(Long roleId) { return roleId != null && roleId > 0; }","tryCatchPattern":"try { return uacRoleUserService.getByUserIdAndRoleId(userId, roleId); } catch (UacBizException e) { if (\"UAC10012001\".equals(e.getCode())) { throw new BadRequestException(\"roleId is required\"); } throw e; }","preventionTips":["Make role selection mandatory in assignment UIs (disable submit until chosen)","Use @NotNull on roleId in request DTOs","Never call binding-existence checks with partially built requests","Unit-test getByUserIdAndRoleId with null roleId"],"tags":["null-argument","java","uac","role-user"],"backgroundTag":"missing-required-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"}