JeffreySu/WeiXinMPSDK · error · MessageHandlerException

微信企业号不支持 IRequestMessageLink 请求类型

Error message

微信企业号不支持 IRequestMessageLink 请求类型

What it means

WorkMessageEntityEnlightener.NewRequestMessageLink creates new entity instances for the message-handler pipeline; the Work (WeCom) platform has no link-type request message, so this method always throws MessageHandlerException instead of returning an entity. It is an intentional capability marker, not a runtime fault.

Solutions

  1. Remove code paths that create IRequestMessageLink entities for the Work platform — WeCom callbacks never produce link messages
  2. Guard the call with a platform check (RequestMsgType) or a try-catch for MessageHandlerException if running shared code
  3. Skip link-message handling in generic pipelines when the target platform is Work

Example fix

// before
var link = enlightener.NewRequestMessageLink();
// after
if (postModel.Platform != PlatformType.WeWork) { var link = enlightener.NewRequestMessageLink(); }
Defensive patterns

Strategy: validation

Validate before calling

if (platform == PlatformType.WeWork) { throw new InvalidOperationException("Link messages are not supported on WeCom"); } var link = enlightener.NewRequestMessageLink();

Type guard

bool SupportsLinkMessages(MessageHandlerEntityEnlightener e) => !(e is WorkMessageEntityEnlightener);

Prevention

When it happens

Trigger: Code explicitly calls NewRequestMessageLink() on a Work message handler's enlightener, or generic message-handler code that iterates all message types (e.g. copying entities, reflection-based pipelines, shared MP code paths) invokes it.

Common situations: Porting MP (Official Account) handler code that references link messages to the Work platform; generic test harnesses instantiating every request entity type; reflection-driven code that enumerates NewRequestMessage* methods.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12). Data as JSON: /api/errors/6573af12032359e2. Report an issue: GitHub.

Appendix: source

Thrown at src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/WorkMessageEntityEnlightener.cs:36

        public override IRequestMessageEvent NewRequestMessageEvent()
        {
            return new RequestMessageEventBase();
        }

        public override IRequestMessageFile NewRequestMessageFile()
        {
            return new RequestMessageFile();
        }

        public override IRequestMessageImage NewRequestMessageImage()
        {
            return new RequestMessageImage();
        }

        public override IRequestMessageLink NewRequestMessageLink()
        {
            throw new MessageHandlerException("微信企业号不支持 IRequestMessageLink 请求类型");
        }

        public override IRequestMessageLocation NewRequestMessageLocation()
        {
            return new RequestMessageLocation();
        }

        public override IRequestMessageShortVideo NewRequestMessageShortVideo()
        {
            return new RequestMessageShortVideo();
        }

        public override IRequestMessageText NewRequestMessageText()
        {
            return new RequestMessageText();
        }

        public override IRequestMessageVideo NewRequestMessageVideo()

View on GitHub (pinned to be573f6f94)