{"record":{"id":"f3df3b6a486cc42d","repo":"JeffreySu/WeiXinMPSDK","slug":"irequestmessagelocation","errorCode":null,"errorMessage":"微信公众号不支持 IRequestMessageLocation 请求类型","messagePattern":"微信公众号不支持 IRequestMessageLocation 请求类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs","lineNumber":39,"sourceCode":"\n        public override IRequestMessageFile NewRequestMessageFile()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageFile 请求类型\");\n        }\n\n        public override IRequestMessageImage NewRequestMessageImage()\n        {\n            return new RequestMessageImage();\n        }\n\n        public override IRequestMessageLink NewRequestMessageLink()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageLink 请求类型\");\n        }\n\n        public override IRequestMessageLocation NewRequestMessageLocation()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageLocation 请求类型\");\n        }\n\n        public override IRequestMessageShortVideo NewRequestMessageShortVideo()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageShortVideo 请求类型\");\n        }\n\n        public override IRequestMessageText NewRequestMessageText()\n        {\n            return new RequestMessageText();\n        }\n\n        public override IRequestMessageVideo NewRequestMessageVideo()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageVideo 请求类型\");\n        }\n\n        public override IRequestMessageVoice NewRequestMessageVoice()","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs#L21-L57","documentation":"WxOpenMessageEntityEnlightener.NewRequestMessageLocation throws MessageHandlerException because location request messages are not part of the mini-program message protocol; the override exists solely to fulfill the base interface. It fires whenever a location-type request is processed by a WxOpen handler.","triggerScenarios":"A MsgType=location message delivered to WxOpenMessageHandler (usually misrouted OfficialAccount traffic) or a direct call to NewRequestMessageLocation on the WxOpen enlightener.","commonSituations":"Callback URL shared between公众号 and小程序; custom dispatcher forwarding all公众号 message types into the WxOpen pipeline; tests enumerating all factory methods.","solutions":["Route location messages to the OfficialAccount MessageHandler","Reject/handle unsupported MsgTypes (location, link, file, video/shortvideo) before passing XML to the WxOpen handler","Catch MessageHandlerException in the processing pipeline and respond with success to stop WeChat retries while logging the event","Verify the mini-program callback only receives its supported message set"],"exampleFix":"// before\nvar result = await wxOpenHandler.ExecuteAsync(xml); // location message -> throws\n// after\ntry {\n    var result = await wxOpenHandler.ExecuteAsync(xml);\n} catch (MessageHandlerException ex) {\n    logger.LogWarning(\"Unsupported msg for WxOpen handler: {0}\", ex.Message);\n    return new WeixinResult(\"success\");\n}","handlingStrategy":"try-catch","validationCode":"if (requestMsgType == RequestMsgType.Location) {\n    return officialAccountHandler.ExecuteAsync(xml); // location belongs to公众号\n}","typeGuard":"bool WxOpenSupportsType(RequestMsgType t) => t is RequestMsgType.Text or RequestMsgType.Image or RequestMsgType.Event;","tryCatchPattern":"try {\n    return await wxOpenHandler.ExecuteAsync(xml);\n} catch (MessageHandlerException ex) when (ex.Message.Contains(\"IRequestMessageLocation\")) {\n    logger.LogWarning(\"Location message sent to WxOpen handler; ignoring\");\n    return new WeixinResult(\"success\");\n}","preventionTips":["Route location-type callbacks to the公众号 MessageHandler","Separate mini-program and公众号 callback endpoints in WeChat configuration","Pre-filter MsgTypes not supported by the WxOpen handler","Reply 'success' on unsupported types to stop platform retries"],"tags":["weixin","wxopen","message-handler","location-message","unsupported"],"backgroundTag":"unsupported-operation","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"}