JeffreySu/WeiXinMPSDK · error · UnknownRequestMsgTypeException
未知的InfoType请求类型
Error message
未知的InfoType请求类型
What it means
OnThirdPartyEventAsync dispatches third-party (应用服务商) events by InfoType (suite_ticket, change_contact, contact sync, etc.). When the InfoType of an authorized-event callback matches no handled case, the default case throws UnknownRequestMsgTypeException. It indicates the library received a provider event type it does not model.
Solutions
- Upgrade Senparc.Weixin.Work so the new InfoType is modeled and dispatched in OnThirdPartyEventAsync
- Override OnThirdPartyEventAsync in a derived handler and add a case for the unknown InfoType
- Catch UnknownRequestMsgTypeException at the suite callback endpoint, log the InfoType, and return 'success' to prevent callback retries
- Inspect the raw decrypted callback XML to confirm the actual InfoType value
Example fix
// before
var result = await messageHandler.BuildResponseMessageAsync();
// after
try { var result = await messageHandler.BuildResponseMessageAsync(); }
catch (UnknownRequestMsgTypeException ex) { _logger.LogWarning(ex, "Unhandled suite InfoType"); return Content("success"); } Defensive patterns
Strategy: try-catch
Validate before calling
if (!Enum.IsDefined(typeof(InfoType), thirdPartyInfo.InfoType)) { return "success"; } Type guard
bool IsKnownInfoType(RequestMessageInfo_Base info) => Enum.IsDefined(typeof(InfoType), info.InfoType);
Try / catch
try { result = await handler.BuildResponseMessageAsync(); } catch (UnknownRequestMsgTypeException ex) { _logger.LogWarning(ex, "Unhandled InfoType: {InfoType}", info?.InfoType); return Content("success"); } Prevention
- Keep the SDK updated for new WeCom suite authorization events
- Log the raw InfoType from decrypted callbacks
- Scope the suite callback URL to expected event types
- Return 'success' for unrecognized InfoType to prevent retry loops
When it happens
Trigger: A WeCom third-party suite callback arrives with an InfoType not covered by the switch — e.g. a new authorization-related InfoType introduced by WeCom after the library release, or a malformed/unexpected callback payload.
Common situations: Suite apps whose callback URL receives events for features the library predates; WeCom API additions (new InfoType values); misconfigured suite callback URL scope.
Related errors
- 未知的Event.change_contact下属请求信息
- 未知的外部联系人事件Event.CHANGE_EXTERNAL_CONTACT下属请求信息
- 未知的企业客户标签变更事件Event.CHANGE_EXTERNAL_Tag下属请求信息
- 未知的客户群变更事件Event.CHANGE_EXTERNAL_CHAT下属请求信息
- 未知的Event下属请求信息
AI-assisted analysis of JeffreySu/WeiXinMPSDK@be573f6f94 (2026-09-12).
Data as JSON: /api/errors/b31728a8ca2ba042.
Report an issue: GitHub.
Appendix: source
Thrown at src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/Async/WorkMessageHandler.Async.cs:1269
case ExternalContactChangeType.del_external_contact:
return OnThirdPartyEvent_ChangeExternalContactDelRequestAsync(
RequestMessage as RequestMessageEvent_Change_ExternalContact_Del);
case ExternalContactChangeType.del_follow_user:
return OnThirdPartyEvent_ChangeExternalContactDelFollowUserRequestAsync(
RequestMessage as RequestMessageEvent_Change_ExternalContact_Del_FollowUser);
case ExternalContactChangeType.transfer_fail:
return OnThirdPartyEvent_ChangeExternalContactTransferFailRequestAsync(
RequestMessage as RequestMessageEvent_Change_ExternalContact_Transfer_Fail);
case ExternalContactChangeType.msg_audit_approved:
return OnThirdPartyEvent_ChangeExternalContactMsgAuditAsync(
RequestMessage as RequestMessageEvent_Change_ExternalContact_MsgAudit);
default:
throw new UnknownRequestMsgTypeException("未知的外部联系人事件Event.CHANGE_EXTERNAL_CONTACT下属请求信息",
null);
}
}
default:
throw new UnknownRequestMsgTypeException("未知的InfoType请求类型", null);
}
}
protected virtual async Task<string> OnThirdPartyEvent_Change_ContactAsync(
RequestMessageInfo_Change_Contact thirdPartyInfo)
{
return await Task.FromResult(OnThirdPartyEvent_Change_Contact(thirdPartyInfo)).ConfigureAwait(false);
}
protected virtual async Task<string> OnThirdPartyEvent_Register_CorpAsync(
RequestMessager_Register_Corp thirdPartyInfo)
{
return await Task.FromResult(OnThirdPartyEvent_Register_Corp(thirdPartyInfo)).ConfigureAwait(false);
}
[Obsolete("请使用修复拼写之后的方法:OnThirdPartyEvent_Register_CorpAsync", true)]
protected virtual Task<string> OnThirdPartyEvent_REGISTER_CORPAsync(
RequestMessager_Register_Corp thirdPartyInfo)View on GitHub (pinned to be573f6f94)