{"record":{"id":"d3ac7ad840728e66","repo":"JeffreySu/WeiXinMPSDK","slug":"infotype-0-requestmessagefactory","errorCode":null,"errorMessage":"InfoType：{0} 在RequestMessageFactory中没有对应的处理程序！","messagePattern":"InfoType：(.+?) 在RequestMessageFactory中没有对应的处理程序！","errorType":"exception","errorClass":"UnknownRequestMsgTypeException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Open/Senparc.Weixin.Open/RequestMessageFactory.cs","lineNumber":120,"sourceCode":"                            requestMessage = new RequestMessageIcpFilingVerify();\n                        break;\n                    case RequestInfoType.notify_apply_icpfiling_result:\n                            requestMessage = new RequestMessageIcpFilingApply();\n                        break;\n                    case RequestInfoType.notify_3rd_wxa_auth:\n                        requestMessage = new RequestMessage3rdWxaAuth();\n                        break;\n                    case RequestInfoType.notify_3rd_wxa_wxverify:\n                        requestMessage = new RequestMessage3rdWxaWxVerify();\n                        break;\n                    case RequestInfoType.order_path_apply_result_notify:\n                        requestMessage = new RequestMessageOrderPathApplyResultNotify();\n                        break;\n                    case RequestInfoType.order_path_audit_result_notify:\n                        requestMessage = new RequestMessageOrderPathAuditResultNotify();\n                        break;\n                    default:\n                        throw new UnknownRequestMsgTypeException(string.Format(\"InfoType：{0} 在RequestMessageFactory中没有对应的处理程序！\", infoType), new ArgumentOutOfRangeException());//为了能够对类型变动最大程度容错（如微信目前还可以对公众账号suscribe等未知类型，但API没有开放），建议在使用的时候catch这个异常\n                }\n                EntityHelper.FillEntityWithXml(requestMessage, doc);\n            }\n            catch (ArgumentException ex)\n            {\n                throw new WeixinException(string.Format(\"RequestMessage转换出错！可能是InfoType不存在！，XML：{0}\", doc.ToString()), ex);\n            }\n            return requestMessage;\n        }\n\n\n        /// <summary>\n        /// 获取XDocument转换后的IRequestMessageBase实例。\n        /// 如果MsgType不存在，抛出UnknownRequestMsgTypeException异常\n        /// </summary>\n        /// <returns></returns>\n        public static IRequestMessageBase GetRequestEntity(string xml)\n        {","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Open/Senparc.Weixin.Open/RequestMessageFactory.cs#L102-L138","documentation":"RequestMessageFactory.GetRequestEntity maps the push XML's InfoType to a concrete request message class; the default switch branch throws UnknownRequestMsgTypeException when the InfoType has no mapped class in this library version. The comment notes the factory is intentionally strict so callers can catch this for forward-compatibility.","triggerScenarios":"WeChat pushes a third-party-platform event whose InfoType is not in the RequestInfoType enum/mapping of the installed Senparc.Weixin.Open version (e.g. a brand-new notify type), while parsing the component callback XML.","commonSituations":"Running an outdated SDK against a WeChat platform that added new event types; test/dev callbacks with fabricated InfoType values; probing pushes from WeChat QA environments.","solutions":["Upgrade Senparc.Weixin.Open to the latest NuGet version to pick up new InfoType mappings.","Catch UnknownRequestMsgTypeException (or WeixinException) when calling GetRequestEntity and handle/log unknown pushes gracefully.","Report or check the InfoType in the raw XML; if it is custom, route it to your own parser before the factory."],"exampleFix":"// before\nvar requestMessage = RequestMessageFactory.GetRequestEntity(doc);\n// after\ntry { var requestMessage = RequestMessageFactory.GetRequestEntity(doc); }\ncatch (UnknownRequestMsgTypeException ex)\n{\n    logger.LogWarning(\"Unknown InfoType push: {Info}\", ex.Message);\n    return; // ack WeChat\n}","handlingStrategy":"try-catch","validationCode":"var infoType = doc.Root?.Element(\"InfoType\")?.Value;\nif (string.IsNullOrEmpty(infoType))\n    throw new InvalidOperationException(\"Push XML missing InfoType\");","typeGuard":"bool IsKnownInfoType(string t) => Enum.IsDefined(typeof(RequestInfoType), t);","tryCatchPattern":"try { var msg = RequestMessageFactory.GetRequestEntity(doc); }\ncatch (UnknownRequestMsgTypeException ex)\n{ logger.LogWarning(ex.Message); return Content(\"success\"); }","preventionTips":["Catch UnknownRequestMsgTypeException around factory calls — the library docs recommend it for forward-compat.","Upgrade the SDK when WeChat announces new event types.","Route unknown InfoTypes to a fallback handler that logs and acks."],"tags":["weixin-open","message-factory","unknown-info-type","version-mismatch"],"backgroundTag":"unsupported-enum-value","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}