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

  1. 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.
  2. Inspect the raw XML push to identify the unknown InfoType; add custom handling in OnThirdPartyMessageRequestAsync or before ExecuteAsync.
  3. 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

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


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)