paascloud/paascloud-master · error · UacBizException

UAC10012001

UAC10012001

Error message

角色ID不能为空

What it means

UacBizException with code UAC10012001 thrown by UacRoleMainController.modifyUacRoleStatusById when the ModifyStatusDto request body has a null id, meaning no role was targeted for the status change. The controller guards every role-status mutation on a non-null roleId before doing any lookup, so the request is rejected before touching the database.

Solutions

  1. Include the role's id in the request body: {"id": 123, "status": "DISABLE"}
  2. Verify the client serializes the ModifyStatusDto with the exact field name 'id'
  3. Add client-side required-field validation before submitting the form
  4. Return a 400-level validation error from the frontend instead of calling the API with incomplete data

Example fix

// before
{"status": "DISABLE"}
// after
{"id": 123, "status": "DISABLE"}
Defensive patterns

Strategy: validation

Validate before calling

if (!dto.id) { throw new Error('roleId is required'); }
// or Java: Preconditions.checkNotNull(modifyStatusDto.getId(), "roleId is required");

Type guard

function hasRoleId(dto) { return dto != null && typeof dto.id === 'number' && dto.id > 0; }

Prevention

When it happens

Trigger: POST /modifyRoleStatusById with a JSON body whose 'id' field is missing or null, e.g. {"status": "DISABLE"}. Also occurs when a client sends an empty body {} or omits the id during a partial update.

Common situations: Frontend form only submits the status field and forgets the hidden roleId; API consumers copy-pasting a curl example without an id; deserialization producing null id when the JSON key is misspelled (e.g. 'roleId' instead of 'id').

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/7b25d29148c16656. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/web/admin/UacRoleMainController.java:120

		uacRoleService.batchDeleteByIdList(deleteIdList);
		return WrapMapper.ok();
	}

	/**
	 * 修改角色状态.
	 *
	 * @param modifyStatusDto the modify status dto
	 *
	 * @return the wrapper
	 */
	@LogAnnotation
	@PostMapping(value = "/modifyRoleStatusById")
	@ApiOperation(httpMethod = "POST", value = "根据角色Id修改角色状态")
	public Wrapper modifyUacRoleStatusById(@ApiParam(name = "modifyRoleStatusDto", value = "修改角色状态数据") @RequestBody ModifyStatusDto modifyStatusDto) {
		logger.info("根据角色Id修改角色状态 modifyStatusDto={}", modifyStatusDto);
		Long roleId = modifyStatusDto.getId();
		if (roleId == null) {
			throw new UacBizException(ErrorCodeEnum.UAC10012001);
		}

		LoginAuthDto loginAuthDto = getLoginAuthDto();
		Long userId = loginAuthDto.getUserId();

		UacRoleUser ru = uacRoleUserService.getByUserIdAndRoleId(userId, roleId);

		if (ru != null && UacRoleStatusEnum.DISABLE.getType().equals(modifyStatusDto.getStatus())) {
			throw new UacBizException(ErrorCodeEnum.UAC10012002);
		}

		UacRole uacRole = new UacRole();
		uacRole.setId(roleId);
		uacRole.setStatus(modifyStatusDto.getStatus());
		uacRole.setUpdateInfo(loginAuthDto);

		int result = uacRoleService.update(uacRole);
		return super.handleResult(result);

View on GitHub (pinned to 781281a950)