{"record":{"id":"2f48e87ba26ee8ce","repo":"JeffreySu/WeiXinMPSDK","slug":"irequestmessagelink-wxopenmessageentityenlightener","errorCode":null,"errorMessage":"微信公众号不支持 IRequestMessageLink 请求类型","messagePattern":"微信公众号不支持 IRequestMessageLink 请求类型","errorType":"exception","errorClass":"MessageHandlerException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs","lineNumber":34,"sourceCode":"\n        public override IRequestMessageEvent NewRequestMessageEvent()\n        {\n            return new RequestMessageEventBase();\n        }\n\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()","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs#L16-L52","documentation":"WxOpenMessageEntityEnlightener.NewRequestMessageLink throws MessageHandlerException because link-type request messages are an OfficialAccount concept and mini-program callbacks never contain them. The method exists only to satisfy the base interface contract.","triggerScenarios":"A MsgType=link message arriving at WxOpenMessageHandler (typically via misrouted OfficialAccount callbacks), or explicit invocation of NewRequestMessageLink on the WxOpen enlightener.","commonSituations":"Same callback endpoint shared by公众号 and小程序; test harness generating link messages against the WxOpen handler; custom message-pump dispatching by MsgType without filtering unsupported ones.","solutions":["Dispatch link messages to the OfficialAccount MessageHandler rather than the WxOpen one","Filter/handle unsupported MsgTypes (link, location, file) before invoking the WxOpen handler","Catch MessageHandlerException around handler execution and log the unsupported type instead of failing the callback","If link messages are legitimately expected, use the公众号 SDK message handler for that endpoint"],"exampleFix":"// before\nswitch (msgType) {\n    case RequestMsgType.Link: return await wxOpenHandler.ExecuteAsync(xml); // throws\n// after\nswitch (msgType) {\n    case RequestMsgType.Link: return await officialHandler.ExecuteAsync(xml);\n    default: return await wxOpenHandler.ExecuteAsync(xml);","handlingStrategy":"try-catch","validationCode":"if (requestMsgType == RequestMsgType.Link) {\n    return officialAccountHandler.ExecuteAsync(xml); // links belong 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(\"IRequestMessageLink\")) {\n    logger.LogWarning(\"Link message sent to WxOpen handler; ignoring\");\n    return new WeixinResult(\"success\");\n}","preventionTips":["Dispatch link messages to the OfficialAccount MessageHandler only","Do not share one callback URL between公众号 and小程序 message pipelines","Whitelist MsgTypes the WxOpen handler supports before executing it","Ack with 'success' to suppress WeChat retry storms on unsupported messages"],"tags":["weixin","wxopen","message-handler","link-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"}