JeffreySu/WeiXinMPSDK · error · UnknownRequestMsgTypeException
未知的InfoType请求类型
Error message
未知的InfoType请求类型
What it means
ThirdPartyMessageHandlerAsync.ExecuteAsync switches on the request message's InfoType and throws UnknownRequestMsgTypeException for any InfoType it has no dedicated handler branch for. This means WeChat pushed a third-party-platform event type the library version does not model.
Solutions
- Upgrade Senparc.Weixin.Open (and the Senparc.Weixin SDK family) to the latest version so the new InfoType has a request message type and handler branch.
- Inspect the raw XML push to identify the unknown InfoType; add custom handling in OnThirdPartyMessageRequestAsync or before ExecuteAsync.
- Wrap Execute in try-catch for UnknownRequestMsgTypeException / MessageHandlerException and log the InfoType instead of failing the callback.
Example fix
// before
await messageHandler.ExecuteAsync(CancellationToken.None);
// after
try { await messageHandler.ExecuteAsync(CancellationToken.None); }
catch (MessageHandlerException ex)
{
logger.LogWarning(ex, "Unhandled InfoType push: {Xml}", rawXml);
return Content("success");
} Defensive patterns
Strategy: try-catch
Validate before calling
var infoType = doc.Root?.Element("InfoType")?.Value;
if (!Enum.TryParse<RequestInfoType>(infoType, out _))
logger.LogWarning("Unknown InfoType push: {InfoType}", infoType); Type guard
bool IsSupportedInfoType(string infoType) => Enum.IsDefined(typeof(RequestInfoType), infoType);
Try / catch
try { await messageHandler.ExecuteAsync(ct); }
catch (MessageHandlerException ex) when (ex.InnerException is UnknownRequestMsgTypeException)
{ logger.LogWarning("Unhandled InfoType push"); return Content("success"); } Prevention
- Keep Senparc.Weixin.Open updated for new WeChat InfoTypes.
- Acknowledge 'success' to WeChat even for unrecognized pushes to avoid retry storms.
- Log raw push XML so new event types can be identified and handled quickly.
When it happens
Trigger: Receiving a WeChat component push (in the authorized-event XML) whose InfoType is not one of the enum values handled in ExecuteAsync's switch — e.g. a newly announced event type your Senparc.Weixin.Open version predates.
Common situations: WeChat adds a new InfoType (like newer order/audit notifies) while the installed Senparc.Weixin.Open package is outdated; malformed or unexpected push payloads routed into the handler.
Related errors
- InfoType: 在RequestMessageFactory中没有对应的处理程序!
- ThirdPartyMessageHandler中ExecuteAsync()过程发生错误:
- 未知的Event下属请求信息
- DefaultMessageHandlerAsyncEvent 类型未作处理:
- 未知的Event下属请求信息
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/ef78fb9ce3691bb7.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Open/Senparc.Weixin.Open/MessageHandlers/ThirdPartyMessageHandlerAsync.cs:148
{
var requestMessage = RequestMessage as RequestMessage3rdWxaWxVerify;
ResponseMessageText = await On3rdWxaWxVerifyRequestAsync(requestMessage, cancellationToken);
}
break;
case RequestInfoType.order_path_apply_result_notify:
{
var requestMessage = RequestMessage as RequestMessageOrderPathApplyResultNotify;
ResponseMessageText = await OnOrderPathApplyResultNotifyRequestAsync(requestMessage, cancellationToken);
}
break;
case RequestInfoType.order_path_audit_result_notify:
{
var requestMessage = RequestMessage as RequestMessageOrderPathAuditResultNotify;
ResponseMessageText = await OnOrderPathAuditResultNotifyRequestAsync(requestMessage, cancellationToken);
}
break;
default:
throw new UnknownRequestMsgTypeException("未知的InfoType请求类型", null);
}
}
catch (Exception ex)
{
throw new MessageHandlerException("ThirdPartyMessageHandler中ExecuteAsync()过程发生错误:" + ex.Message, ex);
}
finally
{
await OnExecutedAsync(cancellationToken);
}
}
public virtual Task OnExecutingAsync(CancellationToken cancellationToken)
{
OnExecuting();
return Task.CompletedTask;
}View on GitHub (pinned to be573f6f94)