{"record":{"id":"ac226762e761ecae","repo":"JeffreySu/WeiXinMPSDK","slug":"infotype-0-requestmessagefactory-ac2267","errorCode":null,"errorMessage":"InfoType：{0} 在RequestMessageFactory中没有对应的处理程序！","messagePattern":"InfoType：(.+?) 在RequestMessageFactory中没有对应的处理程序！","errorType":"exception","errorClass":"UnknownRequestMsgTypeException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Work/Senparc.Weixin.Work/RequestMessageFactory.cs","lineNumber":192,"sourceCode":"                                case \"MSGAUDIT_NOTIFY\":\n                                    requestMessage = new RequestMessageEvent_MsgAuditNotify();\n                                    break;\n                                case \"CREATE\":\n                                    requestMessage = new RequestMessageEvent_Change_ExternalContact_Create();\n                                    break;\n                                case \"UPDATE\":\n                                    requestMessage = new RequestMessageEvent_Change_ExternalContact_Update();\n                                    break;\n                                case \"DISMISS\":\n                                    requestMessage = new RequestMessageEvent_Change_ExternalContact_Dismiss();\n                                    break;\n                                default:\n                                    requestMessage = new RequestMessageEvent_Change_ExternalContact_Base();\n                                    break;\n                            }\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            }\n            else\n            {\n                throw new WeixinException(string.Format(\"RequestMessage转换出错！MsgType和InfoType都不存在！，XML：{0}\", doc.ToString()));\n            }\n\n            return requestMessage;\n        }\n\n\n        /// <summary>","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Work/Senparc.Weixin.Work/RequestMessageFactory.cs#L174-L210","documentation":"RequestMessageFactory.GetRequestEntity received an InfoType (event-driven, e.g. contact/party change callbacks) that has no handler branch in its switch, and threw UnknownRequestMsgTypeException (derived with an ArgumentOutOfRangeException). The comment notes this is done to maximize tolerance for new WeChat types — callers are advised to catch this exception.","triggerScenarios":"A Work callback push arrives with <InfoType> set to a value the installed SDK version doesn't implement (the switch's default branch), e.g. newly added WeChat Work event types.","commonSituations":"New WeChat Work server event pushed before SDK support; running an old Senparc.Weixin.Work version while WeChat enables new callback types on your account.","solutions":["Catch UnknownRequestMsgTypeException around message parsing and reply 'success' to acknowledge unknown events.","Upgrade Senparc.Weixin.Work so the new InfoType is handled.","Log the InfoType from the exception message and, if needed, handle it manually by parsing the XML yourself.","Report/patch the missing InfoType in the factory switch."],"exampleFix":"// before\nvar msg = RequestMessageFactory.GetRequestEntity(...); // throws on new InfoType\n// after\ntry\n{\n    var msg = RequestMessageFactory.GetRequestEntity(...);\n}\ncatch (UnknownRequestMsgTypeException ex)\n{\n    Logger.Warn(ex.Message);\n    return \"success\"; // ack unknown event types\n}","handlingStrategy":"try-catch","validationCode":"var infoType = doc.SelectSingleNode(\"//InfoType\")?.InnerText;\nvar supported = new[] { \"subscribe\", \"unsubscribe\", \"change_contact\", \"change_external_contact\" /* etc per SDK */ };\nif (infoType != null && !supported.Contains(infoType))\n{\n    Logger.Info(\"Unrecognized InfoType, acking: \" + infoType);\n    return \"success\";\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var msg = RequestMessageFactory.GetRequestEntity(...);\n}\ncatch (UnknownRequestMsgTypeException ex)\n{\n    Logger.Warn(ex.Message);\n    return \"success\"; // per SDK guidance, catch this for forward-compat\n}","preventionTips":["Catch UnknownRequestMsgTypeException at the callback boundary — the SDK docs explicitly recommend it for forward compatibility.","Upgrade the SDK when WeChat Work introduces new event types.","Log unknown InfoTypes to track new WeChat features."],"tags":["weixin-work","message-factory","unknown-infotype","callback-event"],"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"}