{"record":{"id":"3d4c58b04ade9331","repo":"paascloud/paascloud-master","slug":"json","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/MdcTopicConsumer.java","lineNumber":63,"sourceCode":"\t * @param tags      the tags\n\t * @param keys      the keys\n\t */\n\t@Transactional(rollbackFor = Exception.class)\n\tpublic void handlerSendSmsTopic(String body, String topicName, String tags, String keys) throws QiniuException {\n\t\tMqMessage.checkMessage(body, keys, topicName);\n\n\t\tif (StringUtils.equals(tags, AliyunMqTopicConstants.MqTagEnum.DELETE_ATTACHMENT.getTag())) {\n\t\t\tList<Long> idList = opcAttachmentService.queryAttachmentByRefNo(body);\n\t\t\tfor (final Long id : idList) {\n\t\t\t\topcAttachmentService.deleteFile(id);\n\t\t\t}\n\t\t} else {\n\t\t\tUpdateAttachmentDto attachmentDto;\n\t\t\ttry {\n\t\t\t\tattachmentDto = JacksonUtil.parseJson(body, UpdateAttachmentDto.class);\n\t\t\t} catch (Exception e) {\n\t\t\t\tlog.error(\"发送短信MQ出现异常={}\", e.getMessage(), e);\n\t\t\t\tthrow new IllegalArgumentException(\"JSON转换异常\", e);\n\t\t\t}\n\t\t\topcAttachmentService.updateAttachment(attachmentDto);\n\t\t}\n\t}\n}\n","sourceCodeStart":45,"sourceCodeEnd":69,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-opc/src/main/java/com/paascloud/provider/consumer/MdcTopicConsumer.java#L45-L69","documentation":"IllegalArgumentException(\"JSON转换异常\") thrown by MdcTopicConsumer.handlerSendSmsTopic when the MQ message body cannot be deserialized into UpdateAttachmentDto via JacksonUtil.parseJson. The consumer guards the parse with try/catch and rethrows so the message is not silently dropped and the failure is visible to the broker's retry/dead-letter handling.","triggerScenarios":"A message published to the attachment topic has a body that is not valid JSON, or valid JSON whose shape does not match UpdateAttachmentDto (missing required fields, wrong types), or is empty/null.","commonSituations":"Producer and consumer use different DTO versions after a schema change; producer sent a plain string/URL instead of a JSON payload; message serialized by a non-Jackson serializer (e.g. raw toString) or with a different encoding.","solutions":["Log and inspect the offending message body (logged at error level) to see whether it is malformed JSON or a schema mismatch","Confirm the producer serializes UpdateAttachmentDto with the same JacksonUtil/Jackson version and field names","Roll out DTO changes to producer and consumer together, or make the consumer tolerant of unknown fields","Send a corrected/republished message or skip it to unblock the queue"],"exampleFix":"// before\nattachmentDto = JacksonUtil.parseJson(body, UpdateAttachmentDto.class);\n// after\nif (PublicUtil.isEmpty(body)) { log.warn(\"skip empty body, keys={}\", keys); return; }\nattachmentDto = JacksonUtil.parseJson(body, UpdateAttachmentDto.class);","handlingStrategy":"try-catch","validationCode":"if (PublicUtil.isEmpty(body)) { log.warn(\"skip empty MQ body\"); return; }\n// producer side:\nString body = JacksonUtil.toJson(updateAttachmentDto);","typeGuard":null,"tryCatchPattern":"try {\n    attachmentDto = JacksonUtil.parseJson(body, UpdateAttachmentDto.class);\n} catch (Exception e) {\n    log.error(\"bad MQ body={}\", body, e);\n    return; // or send to dead-letter topic\n}","preventionTips":["Serialize MQ payloads with JacksonUtil.toJson on the producer, never toString","Keep producer and consumer DTO versions in sync","Prefer tolerant deserialization (ignore unknown fields)","Add a dead-letter path for poison messages"],"tags":["mq-consumer","jackson","deserialization"],"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"}