paascloud/paascloud-master · warning · UacBizException
UAC10012001
UAC10012001
Error message
角色ID不能为空
What it means
UacBizException UAC10012001 ('角色ID不能为空' — role ID cannot be empty) thrown by UacRoleActionServiceImpl.listByRoleId when roleId is null. The service requires a concrete role id to query uac_role_action for the role's action permissions and refuses to run the query with a null key.
Solutions
- Ensure the caller supplies a non-null roleId in the request (check the request body/params actually include it).
- Add client-side validation requiring role selection before calling the permission-list API.
- Check the controller's @RequestParam/@RequestBody binding so the JSON field name matches 'roleId'.
- Default or reject empty roleId upstream with a clear 400 message instead of reaching the service.
Example fix
// before: pass through whatever arrived
List<UacRoleAction> actions = uacRoleActionService.listByRoleId(dto.getRoleId());
// after: validate before calling
if (dto.getRoleId() == null) {
throw new IllegalArgumentException("roleId is required");
}
List<UacRoleAction> actions = uacRoleActionService.listByRoleId(dto.getRoleId()); Defensive patterns
Strategy: validation
Validate before calling
if (roleId == null) {
throw new IllegalArgumentException("roleId is required");
} Type guard
boolean hasRoleId(UacRoleActionQueryDto dto) { return dto != null && dto.getRoleId() != null; } Try / catch
try {
return uacRoleActionService.listByRoleId(roleId);
} catch (UacBizException e) {
if ("UAC10012001".equals(e.getCode())) { /* return empty list or 400 with message */ }
throw e;
} Prevention
- Require role selection in the UI before querying its permissions.
- Annotate DTOs with @NotNull so bean validation rejects nulls at the controller.
- Verify request parameter names match the controller signature.
When it happens
Trigger: Calling listByRoleId(null) — e.g. the REST request omitted roleId, the DTO field was not bound (wrong request param name/type), or upstream code passed an unset Long field.
Common situations: Frontend sends an assign-permission request before a role is selected; query parameter name mismatch between controller and client (@RequestParam("roleId") vs 'id'); Long parsing of an empty string yielding null.
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/7229d7c20a340ada.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacRoleActionServiceImpl.java:31
import java.util.List;
import java.util.Set;
/**
* The class Uac role action service.
*
* @author paascloud.net@gmail.com
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class UacRoleActionServiceImpl extends BaseService<UacRoleAction> implements UacRoleActionService {
@Resource
private UacRoleActionMapper uacRoleActionMapper;
@Override
@Transactional(readOnly = true, rollbackFor = Exception.class)
public List<UacRoleAction> listByRoleId(Long roleId) {
if (roleId == null) {
throw new UacBizException(ErrorCodeEnum.UAC10012001);
}
UacRoleAction roleMenu = new UacRoleAction();
roleMenu.setRoleId(roleId);
return uacRoleActionMapper.select(roleMenu);
}
@Override
public void deleteByRoleId(Long roleId) {
if (roleId == null) {
throw new UacBizException(ErrorCodeEnum.UAC10012001);
}
UacRoleAction roleMenu = new UacRoleAction();
roleMenu.setRoleId(roleId);
uacRoleActionMapper.delete(roleMenu);
}
@Override
public void insert(Long roleId, Set<Long> actionIdList) {View on GitHub (pinned to 781281a950)