{"record":{"id":"20c41da164d1bb40","repo":"paascloud/paascloud-master","slug":"json-20c41d","errorCode":null,"errorMessage":"JSON转换异常","messagePattern":"JSON转换异常","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/consumer/OptSendSmsTopicConsumer.java","lineNumber":51,"sourceCode":"\t@Resource\n\tprivate OptSmsService smsService;\n\n\t/**\n\t * Handler send sms topic.\n\t *\n\t * @param body      the body\n\t * @param topicName the topic name\n\t * @param tags      the tags\n\t * @param keys      the keys\n\t */\n\tpublic void handlerSendSmsTopic(String body, String topicName, String tags, String keys) {\n\t\tMqMessage.checkMessage(body, keys, topicName);\n\t\tSendSmsRequest sendSmsRequest;\n\t\ttry {\n\t\t\tsendSmsRequest = JacksonUtil.parseJson(body, SendSmsRequest.class);\n\t\t} catch (Exception e) {\n\t\t\tlog.error(\"发送短信MQ出现异常={}\", e.getMessage(), e);\n\t\t\tthrow new IllegalArgumentException(\"JSON转换异常\", e);\n\t\t}\n\t\tString ipAddr = sendSmsRequest.getOutId();\n\t\tif (StringUtils.isEmpty(ipAddr)) {\n\t\t\tthrow new IllegalArgumentException(\"outId不能为空\");\n\t\t}\n\t\tsmsService.sendSms(sendSmsRequest);\n\t}\n}\n","sourceCodeStart":33,"sourceCodeEnd":60,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/consumer/OptSendSmsTopicConsumer.java#L33-L60","documentation":"IllegalArgumentException(\"JSON转换异常\") thrown by OptSendSmsTopicConsumer.handlerSendSmsTopic when the SMS-topic message body fails to deserialize into SendSmsRequest via JacksonUtil.parseJson. Parsing is wrapped in try/catch and rethrown so malformed messages are rejected rather than processed with garbage data.","triggerScenarios":"MQ body on the send-sms topic is empty, invalid JSON, or JSON that does not match SendSmsRequest (wrong/missing fields, type mismatches such as phone number as number vs string).","commonSituations":"Producer/consumer DTO version skew after schema changes; producer sent the wrong payload type (e.g. the email request) to the SMS topic; message serialized with a different library or as plain text; encoding issues.","solutions":["Read the error-level log containing the message body to identify malformed JSON vs schema mismatch","Ensure the producer serializes SendSmsRequest with JacksonUtil.toJson and same field names","Deploy producer and consumer together when SendSmsRequest changes","Republish a valid message or remove the poison message to unblock the queue"],"exampleFix":"// before\nsendSmsRequest = JacksonUtil.parseJson(body, SendSmsRequest.class);\n// after\nif (PublicUtil.isEmpty(body)) { log.warn(\"skip empty sms body, keys={}\", keys); return; }\nsendSmsRequest = JacksonUtil.parseJson(body, SendSmsRequest.class);","handlingStrategy":"try-catch","validationCode":"if (PublicUtil.isEmpty(body)) { log.warn(\"skip empty sms MQ body\"); return; }\n// producer side:\nString body = JacksonUtil.toJson(sendSmsRequest);","typeGuard":null,"tryCatchPattern":"try {\n    sendSmsRequest = JacksonUtil.parseJson(body, SendSmsRequest.class);\n} catch (Exception e) {\n    log.error(\"bad sms MQ body={}\", body, e);\n    return; // route to dead-letter topic\n}","preventionTips":["Always serialize SendSmsRequest with the same JSON library end-to-end","Keep DTO field names stable across services","Reject-and-dead-letter malformed messages instead of crash-looping","Write an integration test publishing/consuming a sample message"],"tags":["mq-consumer","jackson","deserialization","sms"],"backgroundTag":"json-unmarshal-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"}