paascloud/paascloud-master · error · UacBizException

UAC10012001

UAC10012001

Error message

ErrorCodeEnum.UAC10012001

What it means

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).

Solutions

  1. Set/validate roleId before calling getByUserIdAndRoleId
  2. Enforce @NotNull on roleId in the request DTO/controller validation
  3. In the UI, disable submit until a role is selected
  4. Catch UacBizException UAC10012001 and prompt the user to select a role

Example fix

// before
if (request.getRoleId() != null) {
    uacRoleUserService.getByUserIdAndRoleId(request.getUserId(), request.getRoleId());
}
// after
Preconditions.checkNotNull(request.getRoleId(), "roleId required");
uacRoleUserService.getByUserIdAndRoleId(request.getUserId(), request.getRoleId());
Defensive patterns

Strategy: validation

Validate before calling

if (roleId == null) { throw new IllegalArgumentException("roleId is required"); }

Type guard

boolean validRoleId(Long roleId) { return roleId != null && roleId > 0; }

Try / catch

try { return uacRoleUserService.getByUserIdAndRoleId(userId, roleId); } catch (UacBizException e) { if ("UAC10012001".equals(e.getCode())) { throw new BadRequestException("roleId is required"); } throw e; }

Prevention

When it happens

Trigger: Calling getByUserIdAndRoleId(userId, null) — the role selection was not sent or the DTO field was never set when checking/creating a user-role binding.

Common situations: UIs that allow submitting a role-assignment form without picking a role, API calls omitting roleId, or programmatic DTO construction missing setRoleId.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/72dd99490b9d13c4. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleUserServiceImpl.java:61

	@Transactional(readOnly = true, rollbackFor = Exception.class)
	public List<UacRoleUser> queryByUserId(Long userId) {
		if (null == userId) {
			throw new UacBizException(ErrorCodeEnum.UAC10011001);
		}

		return uacRoleUserMapper.listByUserId(userId);
	}

	@Override
	@Transactional(readOnly = true, rollbackFor = Exception.class)
	public UacRoleUser getByUserIdAndRoleId(Long userId, Long roleId) {

		if (null == userId) {
			throw new UacBizException(ErrorCodeEnum.UAC10011001);
		}

		if (null == roleId) {
			throw new UacBizException(ErrorCodeEnum.UAC10012001);
		}

		return uacRoleUserMapper.getByUserIdAndRoleId(userId, roleId);
	}

	@Override
	public int saveRoleUser(Long userId, Long roleId) {
		if (userId == null) {
			throw new UacBizException(ErrorCodeEnum.UAC10011001);
		}
		if (roleId == null) {
			throw new UacBizException(ErrorCodeEnum.UAC10012001);
		}

		UacRoleUser roleUser = new UacRoleUser();
		roleUser.setUserId(userId);
		roleUser.setRoleId(roleId);
		return uacRoleUserMapper.insertSelective(roleUser);

View on GitHub (pinned to 781281a950)