{"record":{"id":"5c19cefbee4e726c","repo":"JeffreySu/WeiXinMPSDK","slug":"event","errorCode":null,"errorMessage":"未知的Event下属请求信息","messagePattern":"未知的Event下属请求信息","errorType":"exception","errorClass":"UnknownRequestMsgTypeException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.MP/Senparc.Weixin.MP/MessageHandlers/Async/MessageHandlerAsync.Event.cs","lineNumber":257,"sourceCode":"\n                case Event.giftcard_send_to_friend:\n                    responseMessage = await OnEvent_GiftCard_Send_To_FriendRequestAsync(RequestMessage as RequestMessageEvent_GiftCard_Send_To_Friend).ConfigureAwait(false);\n                    break;\n\n                case Event.giftcard_user_accept:\n                    responseMessage = await OnEvent_GiftCard_User_AcceptRequestAsync(RequestMessage as RequestMessageEvent_GiftCard_User_Accept).ConfigureAwait(false);\n                    break;\n\n                #endregion\n\n                #region 微信电子发票\n                case Event.user_authorize_invoice:\n                    responseMessage = await OnEvent_User_Authorize_InvoiceAsync(RequestMessage as RequestMessageEvent_User_Authorize_Invoice).ConfigureAwait(false);\n                    break;\n                #endregion\n\n                default:\n                    throw new Exceptions.UnknownRequestMsgTypeException(\"未知的Event下属请求信息\", null);\n            }\n\n            string d = null;\n            string s = null;\n            string n = s ?? d ?? \"1\";\n\n            return responseMessage;\n        }\n\n        #region Event下属分类，接收事件方法\n\n        /// <summary>\n        /// 【异步方法】Event事件类型请求之用户资料变更\n        /// </summary>\n        /// <param name=\"requestMessage\"></param>\n        /// <returns></returns>\n        public virtual async Task<IResponseMessageBase> OnEvent_UserInfoModifiedRequesAsync(RequestMessageEvent_UserInfoModified requestMessage)\n        {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.MP/Senparc.Weixin.MP/MessageHandlers/Async/MessageHandlerAsync.Event.cs#L239-L275","documentation":"OnEventRequestAsync dispatches push events (Event enum) to typed OnEvent_* handlers. When the event's MsgType is Event but the specific event value has no matching case in the switch, the library throws UnknownRequestMsgTypeException('未知的Event下属请求信息'). This guards against unhandled/new WeChat event types rather than silently dropping them.","triggerScenarios":"WeChat server pushes an event that this version of Senparc.Weixin.MP does not map in its switch (new WeChat event types, beta events, or event values enabled on the WeChat MP console but unsupported by the installed SDK version); a custom/modified Event enum deserialization producing an unmapped value.","commonSituations":"Enabling new WeChat features (e.g. new invoice, card, or mini-program events) in the MP admin console while running an older SDK; WeChat adding an event type after the SDK release; forwarding messages from a test account issuing events the SDK predates.","solutions":["Upgrade Senparc.Weixin / Senparc.Weixin.MP to the latest version so new event types are mapped.","Override OnEventRequestAsync (or the DefaultAsyncMessageHandler) in your MessageHandler subclass to catch UnknownRequestMsgTypeException and return a success/empty response to WeChat.","Log the raw request XML (RequestMessage.Event) to identify the unknown event and handle it in an override.","Avoid enabling unsupported event features in the WeChat console until the SDK supports them."],"exampleFix":"// before\npublic override async Task<IResponseMessageBase> OnEventRequestAsync(RequestMessageEvent requestMessage)\n{\n    return await base.OnEventRequestAsync(requestMessage); // throws on unknown event\n}\n// after\npublic override async Task<IResponseMessageBase> OnEventRequestAsync(RequestMessageEvent requestMessage)\n{\n    try\n    {\n        return await base.OnEventRequestAsync(requestMessage);\n    }\n    catch (UnknownRequestMsgTypeException)\n    {\n        Log.Warn($\"Unhandled event: {requestMessage.Event}\");\n        return base.CreateResponseMessage<ResponseMessageNoResponse>();\n    }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"bool isSupportedEvent = Enum.IsDefined(typeof(Event), requestMessage.Event);","tryCatchPattern":"try\n{\n    response = await handler.OnEventRequestAsync(eventMessage);\n}\ncatch (UnknownRequestMsgTypeException ex)\n{\n    log.Warn($\"Unknown WeChat event: {ex.Message}\");\n    response = handler.CreateResponseMessage<ResponseMessageNoResponse>();\n}","preventionTips":["Keep Senparc.Weixin.MP packages updated to track new WeChat event types.","Override OnEventRequestAsync with a default fallback instead of relying on base throwing.","Log raw callback XML so unknown events can be identified and added later.","Only enable event push features in the WeChat console that your SDK version supports."],"tags":["wechat-sdk","csharp","message-handler","unhandled-event","event-dispatch"],"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"}