paascloud/paascloud-master · error · IllegalArgumentException

UAC10012001

UAC10012001

Error message

角色ID不能为空

What it means

IllegalArgumentException carrying message of UAC10012001 ('角色ID不能为空') thrown by UacRoleServiceImpl.deleteRoleById when roleId is null. Unlike the other errors in this family, a plain IllegalArgumentException is used; the null ID cannot identify a role to delete.

Solutions

  1. Pass a valid roleId from the selected row
  2. Validate the id request parameter before calling the service
  3. Handle IllegalArgumentException in the controller and return a 'role id required' response

Example fix

// before
uacRoleService.deleteRoleById(request.getParameter("roleId") == null ? null : Long.valueOf(request.getParameter("roleId")));
// after
Long roleId = Long.valueOf(request.getParameter("roleId"));
uacRoleService.deleteRoleById(roleId);
Defensive patterns

Strategy: validation

Validate before calling

if (roleId == null) {
    return Result.error("roleId is required");
}

Type guard

boolean isDeletable(Long roleId) { return roleId != null && roleId > 0 && !Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID); }

Try / catch

try {
    uacRoleService.deleteRoleById(roleId);
} catch (IllegalArgumentException e) {
    return Result.error("角色ID不能为空");
}

Prevention

When it happens

Trigger: Calling uacRoleService.deleteRoleById(null), e.g. a delete request whose id parameter was missing or failed binding.

Common situations: Delete button rendered without a role context; REST path variable omitted; stale UI state after the role was deleted by another user.

Related errors


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

Appendix: source

Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleServiceImpl.java:73

	private UacRoleActionService uacRoleActionService;

	@Override
	@Transactional(readOnly = true, rollbackFor = Exception.class)
	public UacRole findByRoleCode(String roleCode) {
		return uacRoleMapper.findByRoleCode(roleCode);
	}

	@Override
	@Transactional(readOnly = true, rollbackFor = Exception.class)
	public List<RoleVo> queryRoleListWithPage(UacRole role) {
		return uacRoleMapper.queryRoleListWithPage(role);
	}

	@Override
	public int deleteRoleById(Long roleId) {
		//查询该角色下是否有用户绑定, 有的话提醒不能删除
		if (null == roleId) {
			throw new IllegalArgumentException(ErrorCodeEnum.UAC10012001.msg());
		}

		// 超级管理员不能删除
		if (Objects.equals(roleId, GlobalConstant.Sys.SUPER_MANAGER_ROLE_ID)) {
			throw new UacBizException(ErrorCodeEnum.UAC10012003);
		}

		List<UacRoleUser> uruList = uacRoleUserService.listByRoleId(roleId);

		if (!uruList.isEmpty()) {
			uacRoleUserService.deleteByRoleId(roleId);
		}

		uacRoleActionService.deleteByRoleId(roleId);
		uacRoleMenuService.deleteByRoleId(roleId);
		return uacRoleMapper.deleteByPrimaryKey(roleId);
	}

View on GitHub (pinned to 781281a950)