paascloud/paascloud-master · error · IllegalArgumentException
outId不能为空
Error message
outId不能为空
What it means
IllegalArgumentException("outId不能为空") thrown by OptSendSmsTopicConsumer.handlerSendSmsTopic after successful deserialization when SendSmsRequest.outId is empty. outId is required for the Aliyun SMS call (it maps the send request to a business identifier), so the consumer rejects the message before invoking smsService.sendSms.
Solutions
- Fix the producer to always set outId before publishing to the SMS topic
- Check field naming/annotations so outId actually maps during JSON deserialization
- If outId is genuinely optional for some templates, guard conditionally instead of rejecting
- Republish the failed message with outId set
Example fix
// before SendSmsRequest sendSmsRequest = new SendSmsRequest(); sendSmsRequest.setPhoneNumber(...); // after SendSmsRequest sendSmsRequest = new SendSmsRequest(); sendSmsRequest.setPhoneNumber(...); Preconditions.checkArgument(StringUtils.isNotEmpty(outId), "outId must be set"); sendSmsRequest.setOutId(outId);
Defensive patterns
Strategy: validation
Validate before calling
if (sendSmsRequest == null || StringUtils.isEmpty(sendSmsRequest.getOutId())) {
log.warn("sms message missing outId, discarding");
return;
} Type guard
if (sendSmsRequest == null) { return; }
String outId = sendSmsRequest.getOutId();
if (outId == null || outId.trim().isEmpty()) { return; } Try / catch
try { smsService.sendSms(sendSmsRequest); } catch (IllegalArgumentException e) { log.error("invalid sms request: {}", e.getMessage()); } Prevention
- Set outId on the producer before publishing
- Validate SendSmsRequest fields at the producer boundary
- Keep DTO field mappings consistent (annotations) so outId survives serialization
- Add a producer-side unit test asserting outId is populated
When it happens
Trigger: A message on the SMS topic parses fine but was published without setting outId, or the producer populates a differently named field (so outId deserializes to null), or outId was intentionally blank for templates not requiring it but the consumer always requires it.
Common situations: Producer DTO changed to make outId optional; producer code path that builds SendSmsRequest without outId; copy-pasted producer code sending the email payload shape to the SMS topic.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/9135d5a9527440fb.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/consumer/OptSendSmsTopicConsumer.java:55
* Handler send sms topic.
*
* @param body the body
* @param topicName the topic name
* @param tags the tags
* @param keys the keys
*/
public void handlerSendSmsTopic(String body, String topicName, String tags, String keys) {
MqMessage.checkMessage(body, keys, topicName);
SendSmsRequest sendSmsRequest;
try {
sendSmsRequest = JacksonUtil.parseJson(body, SendSmsRequest.class);
} catch (Exception e) {
log.error("发送短信MQ出现异常={}", e.getMessage(), e);
throw new IllegalArgumentException("JSON转换异常", e);
}
String ipAddr = sendSmsRequest.getOutId();
if (StringUtils.isEmpty(ipAddr)) {
throw new IllegalArgumentException("outId不能为空");
}
smsService.sendSms(sendSmsRequest);
}
}
View on GitHub (pinned to 781281a950)