{"record":{"id":"cabcff1e017b997d","repo":"JeffreySu/WeiXinMPSDK","slug":"iresponsemessagemusic-wxopenmessageentityenlightener","errorCode":null,"errorMessage":"微信公众号不支持 IResponseMessageMusic 响应类型","messagePattern":"微信公众号不支持 IResponseMessageMusic 响应类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs","lineNumber":74,"sourceCode":"\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\n        public override IResponseMessageTransfer_Customer_Service NewResponseMessageTransfer_Customer_Service()\n        {\n            return new ResponseMessageTransfer_Customer_Service();\n        }\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs#L56-L92","documentation":"WxOpenMessageEntityEnlightener.NewResponseMessageMusic unconditionally throws MessageHandlerException. Music replies are a 公众号 (MP) response type not supported by the WxOpen Mini Program message pipeline, so the factory throws instead of constructing the entity.","triggerScenarios":"Calling NewResponseMessageMusic() on the WxOpen enlightener, typically from a WxOpen On* handler attempting to reply with a music message or shared MP reply code.","commonSituations":"Porting MP music-reply handlers to WxOpen; generic response factories that create music replies per message type regardless of platform.","solutions":["Reply with ResponseMessageText or transfer to customer service instead of a music message in WxOpen.","Gate music replies behind a platform check (only in MP handlers).","Push media content via customer-service messages handled on the MP side."],"exampleFix":"// before\nvar music = enlightener.NewResponseMessageMusic();\n// after\nvar reply = enlightener.NewResponseMessageText();\nreply.Content = \"请在公众号中查看音乐内容\";","handlingStrategy":"validation","validationCode":"if (platform == Platform.WxOpen && replyKind == ReplyKind.Music)\n    replyKind = ReplyKind.Text; // music replies unsupported in WxOpen","typeGuard":"static bool IsWxOpenUnsupportedResponse(IResponseMessageBase r) =>\n    r is IResponseMessageMusic or IResponseMessageVideo or IResponseMessageVoice or IResponseMessageNews or IResponseMessageImage or IResponseMessageMpNews;","tryCatchPattern":"try\n{\n    var music = enlightener.NewResponseMessageMusic();\n}\ncatch (MessageHandlerException)\n{\n    var reply = enlightener.NewResponseMessageText(); // fallback\n}","preventionTips":["Restrict music replies to MP handlers.","Use customer-service transfer when media replies are needed from WxOpen.","Document supported WxOpen response types for your team."],"tags":["wxopen","message-handler","unsupported-response-type","music"],"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"}