{"record":{"id":"321b5c5197a81322","repo":"JeffreySu/WeiXinMPSDK","slug":"iresponsemessagempnews-wxopenmessageentityenlightener","errorCode":null,"errorMessage":"微信公众号不支持 IResponseMessageMpNews 响应类型","messagePattern":"微信公众号不支持 IResponseMessageMpNews 响应类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs","lineNumber":69,"sourceCode":"\n        public override IRequestMessageVideo NewRequestMessageVideo()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageVideo 请求类型\");\n        }\n\n        public override IRequestMessageVoice NewRequestMessageVoice()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IRequestMessageVoice 请求类型\");\n        }\n\n        public override IResponseMessageImage NewResponseMessageImage()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageImage 响应类型\");\n        }\n\n        public override IResponseMessageMpNews NewResponseMessageMpNews()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageMpNews 响应类型\");\n        }\n\n        public override IResponseMessageMusic NewResponseMessageMusic()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageMusic 响应类型\");\n        }\n\n        public override IResponseMessageNews NewResponseMessageNews()\n        {\n            throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageNews 响应类型\");\n        }\n\n        public override IResponseMessageText NewResponseMessageText()\n        {\n            return new Senparc.Weixin.MP.Entities.ResponseMessageText();\n            //throw new MessageHandlerException(\"微信公众号不支持 IResponseMessageText 响应类型\");\n        }\n","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs#L51-L87","documentation":"WxOpenMessageEntityEnlightener.NewResponseMessageMpNews unconditionally throws MessageHandlerException. MpNews is a 公众号-only response type; the WxOpen factory deliberately rejects building it because Mini Program replies cannot be MpNews articles.","triggerScenarios":"Calling NewResponseMessageMpNews() on the WxOpen enlightener, e.g. a WxOpen handler returning an MpNews response or shared reply-generation code that emits MpNews for all platforms.","commonSituations":"Reusing MP mass-reply templates in WxOpen; generic handler frameworks that map message types to responses without platform checks.","solutions":["Use a WxOpen-supported response such as ResponseMessageText or ResponseMessageTransfer_Customer_Service.","Remove MpNews reply logic from the WxOpen handler.","Send article-style content through customer-service channels on the MP side instead."],"exampleFix":"// before\nvar resp = enlightener.NewResponseMessageMpNews();\n// after\nvar resp = (Senparc.Weixin.MP.Entities.IResponseMessageBase)enlightener.NewResponseMessageText();","handlingStrategy":"validation","validationCode":"if (desiredResponse == ResponseKind.MpNews && platform == Platform.WxOpen)\n    desiredResponse = ResponseKind.Text; // MpNews is MP-only","typeGuard":"static bool IsMpNewsResponse(IResponseMessageBase r) => r is IResponseMessageMpNews; // if true, invalid for WxOpen","tryCatchPattern":"try\n{\n    var resp = enlightener.NewResponseMessageMpNews();\n}\ncatch (MessageHandlerException)\n{\n    resp = enlightener.NewResponseMessageText();\n}","preventionTips":["Gate MpNews replies to MP handlers only.","Centralize response-type selection in one factory with platform awareness.","Add a CI test replaying each response type per platform."],"tags":["wxopen","message-handler","unsupported-response-type","mpnews"],"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"}