JeffreySu/WeiXinMPSDK · error · MessageHandlerException
微信公众号不支持 IResponseMessageMpNews 响应类型
Error message
微信公众号不支持 IResponseMessageMpNews 响应类型
What it means
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.
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.
Example fix
// before var resp = enlightener.NewResponseMessageMpNews(); // after var resp = (Senparc.Weixin.MP.Entities.IResponseMessageBase)enlightener.NewResponseMessageText();
Defensive patterns
Strategy: validation
Validate before calling
if (desiredResponse == ResponseKind.MpNews && platform == Platform.WxOpen)
desiredResponse = ResponseKind.Text; // MpNews is MP-only Type guard
static bool IsMpNewsResponse(IResponseMessageBase r) => r is IResponseMessageMpNews; // if true, invalid for WxOpen
Try / catch
try
{
var resp = enlightener.NewResponseMessageMpNews();
}
catch (MessageHandlerException)
{
resp = enlightener.NewResponseMessageText();
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Reusing MP mass-reply templates in WxOpen; generic handler frameworks that map message types to responses without platform checks.
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
- 微信公众号不支持 IResponseMessageImage 响应类型
- 微信公众号不支持 IResponseMessageMusic 响应类型
- 微信公众号不支持 IResponseMessageNews 响应类型
- 微信公众号不支持 IResponseMessageVideo 响应类型
- 微信公众号不支持 IResponseMessageVoice 响应类型
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/321b5c5197a81322.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/MessageHandlers/WxOpenMessageEntityEnlightener.cs:69
public override IRequestMessageVideo NewRequestMessageVideo()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageVideo 请求类型");
}
public override IRequestMessageVoice NewRequestMessageVoice()
{
throw new MessageHandlerException("微信公众号不支持 IRequestMessageVoice 请求类型");
}
public override IResponseMessageImage NewResponseMessageImage()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageImage 响应类型");
}
public override IResponseMessageMpNews NewResponseMessageMpNews()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageMpNews 响应类型");
}
public override IResponseMessageMusic NewResponseMessageMusic()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageMusic 响应类型");
}
public override IResponseMessageNews NewResponseMessageNews()
{
throw new MessageHandlerException("微信公众号不支持 IResponseMessageNews 响应类型");
}
public override IResponseMessageText NewResponseMessageText()
{
return new Senparc.Weixin.MP.Entities.ResponseMessageText();
//throw new MessageHandlerException("微信公众号不支持 IResponseMessageText 响应类型");
}
View on GitHub (pinned to be573f6f94)