{"record":{"id":"1832d22bf30fc5f8","repo":"paascloud/paascloud-master","slug":"uac10011021","errorCode":"UAC10011021","errorMessage":"UAC10011021","messagePattern":"UAC10011021","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/mq/producer/EmailProducer.java","lineNumber":67,"sourceCode":"\tpublic MqMessageData sendEmailMq(Set<String> emailSet, UacEmailTemplateEnum emailTemplateEnum, AliyunMqTopicConstants.MqTagEnum tagEnum, Map<String, Object> param) {\n\t\tlog.info(\"pcSendEmailRequest - 发送邮件MQ. emailSet={}, param={}\", emailSet, param);\n\t\tString msgBody;\n\t\ttry {\n\n\t\t\tPreconditions.checkArgument(emailTemplateEnum != null, \"邮箱模板信息不存在\");\n\t\t\tPcSendEmailRequest request = new PcSendEmailRequest();\n\n\t\t\tString templateLocation = emailTemplateEnum.getLocation();\n\t\t\tString text = uacFreeMarkerService.getTemplate(param, templateLocation);\n\n\t\t\trequest.setText(text);\n\t\t\trequest.setTo(emailSet);\n\t\t\trequest.setSubject(emailTemplateEnum.getSubject());\n\n\t\t\tmsgBody = JSON.toJSONString(request);\n\t\t} catch (Exception e) {\n\t\t\tlog.error(\"发送邮件验证码 smsMessage转换为json字符串失败\", e);\n\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011021);\n\t\t}\n\t\tString topic = tagEnum.getTopic();\n\t\tString tag = tagEnum.getTag();\n\t\tString key = RedisKeyUtil.createMqKey(topic, tag, emailSet.toString(), msgBody);\n\t\treturn new MqMessageData(msgBody, topic, tag, key);\n\t}\n}\n","sourceCodeStart":49,"sourceCodeEnd":75,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/mq/producer/EmailProducer.java#L49-L75","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\npublic String getAttachments() {\n    return attachments.stream().map(a -> a.getOwner().getEmail())...; // throws NPE\n}\n// after\npublic String getAttachments() {\n    return attachments == null ? null : attachments.stream().map(Attachment::getName).collect(Collectors.joining(\",\"));\n}","handlingStrategy":"try-catch","validationCode":"try { JSON.parseObject(JSON.toJSONString(request), SendEmailRequest.class); } catch (Exception e) { /* invalid request graph */ }","typeGuard":null,"tryCatchPattern":"try { msgBody = JSON.toJSONString(request); } catch (Exception e) { log.error(\"email request serialization failed, to={}\", request.getTo(), e); throw new UacBizException(ErrorCodeEnum.UAC10011021); }","preventionTips":["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"],"tags":["mq","json-serialization","email","fastjson"],"backgroundTag":"json-serialization-failed","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}