paascloud/paascloud-master · error · UacBizException
UAC10011021
UAC10011021
Error message
UAC10011021
What it means
UacBizException with code UAC10011021 is thrown by EmailProducer.sendEmailMq when serializing the SendEmailRequest object to a JSON string with JSON.toJSONString() fails. The failure is caught, logged as "发送邮件验证码 smsMessage转换为json字符串失败" (email message conversion to JSON string failed), and rethrown as a business exception. This blocks the email verification-code message from being published to RocketMQ.
Solutions
- Inspect the logged stack trace under "发送邮件验证码 smsMessage转换为json字符串失败" to find the exact serialization failure
- Remove or fix getters on SendEmailRequest that throw or reference parent objects (fastjson circular reference)
- Add SerializerFeature.DisableCircularReferenceDetect or use a simple DTO with plain String/primitive fields
- Verify the fastjson dependency version matches the one the project was built against
Example fix
// before
public String getAttachments() {
return attachments.stream().map(a -> a.getOwner().getEmail())...; // throws NPE
}
// after
public String getAttachments() {
return attachments == null ? null : attachments.stream().map(Attachment::getName).collect(Collectors.joining(","));
} Defensive patterns
Strategy: try-catch
Validate before calling
try { JSON.parseObject(JSON.toJSONString(request), SendEmailRequest.class); } catch (Exception e) { /* invalid request graph */ } Try / catch
try { msgBody = JSON.toJSONString(request); } catch (Exception e) { log.error("email request serialization failed, to={}", request.getTo(), e); throw new UacBizException(ErrorCodeEnum.UAC10011021); } Prevention
- Keep MQ payload DTOs limited to plain fields and simple getters
- Add a unit test that serializes every email template request variant
- Disable fastjson circular references explicitly or restructure object graphs
- Pin fastjson version in the parent POM and check upgrades in CI
When it happens
Trigger: Calling sendEmailMq with a SendEmailRequest whose fields (to email set, subject from EmailTemplateEnum) cause fastjson serialization to fail — e.g. circular references or non-serializable getters in the request object, or a serialization-time RuntimeException in a custom getter.
Common situations: Customizing SendEmailRequest with a getter that throws or creates a fastjson circular reference ($ref cycle); incompatible fastjson versions with strict type handling; corrupt EmailTemplateEnum data leading to unexpected object graphs.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10).
Data as JSON: /api/errors/1832d22bf30fc5f8.
Report an issue: GitHub.
Appendix: source
Thrown at paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/mq/producer/EmailProducer.java:67
public MqMessageData sendEmailMq(Set<String> emailSet, UacEmailTemplateEnum emailTemplateEnum, AliyunMqTopicConstants.MqTagEnum tagEnum, Map<String, Object> param) {
log.info("pcSendEmailRequest - 发送邮件MQ. emailSet={}, param={}", emailSet, param);
String msgBody;
try {
Preconditions.checkArgument(emailTemplateEnum != null, "邮箱模板信息不存在");
PcSendEmailRequest request = new PcSendEmailRequest();
String templateLocation = emailTemplateEnum.getLocation();
String text = uacFreeMarkerService.getTemplate(param, templateLocation);
request.setText(text);
request.setTo(emailSet);
request.setSubject(emailTemplateEnum.getSubject());
msgBody = JSON.toJSONString(request);
} catch (Exception e) {
log.error("发送邮件验证码 smsMessage转换为json字符串失败", e);
throw new UacBizException(ErrorCodeEnum.UAC10011021);
}
String topic = tagEnum.getTopic();
String tag = tagEnum.getTag();
String key = RedisKeyUtil.createMqKey(topic, tag, emailSet.toString(), msgBody);
return new MqMessageData(msgBody, topic, tag, key);
}
}
View on GitHub (pinned to 781281a950)