{"record":{"id":"b31728a8ca2ba042","repo":"JeffreySu/WeiXinMPSDK","slug":"infotype-workmessagehandler-async","errorCode":null,"errorMessage":"未知的InfoType请求类型","messagePattern":"未知的InfoType请求类型","errorType":"exception","errorClass":"UnknownRequestMsgTypeException","httpStatus":null,"severity":"error","filePath":"src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/Async/WorkMessageHandler.Async.cs","lineNumber":1269,"sourceCode":"                        case ExternalContactChangeType.del_external_contact:\n                            return OnThirdPartyEvent_ChangeExternalContactDelRequestAsync(\n                                RequestMessage as RequestMessageEvent_Change_ExternalContact_Del);\n                        case ExternalContactChangeType.del_follow_user:\n                            return OnThirdPartyEvent_ChangeExternalContactDelFollowUserRequestAsync(\n                                RequestMessage as RequestMessageEvent_Change_ExternalContact_Del_FollowUser);\n                        case ExternalContactChangeType.transfer_fail:\n                            return OnThirdPartyEvent_ChangeExternalContactTransferFailRequestAsync(\n                                RequestMessage as RequestMessageEvent_Change_ExternalContact_Transfer_Fail);\n                        case ExternalContactChangeType.msg_audit_approved:\n                            return OnThirdPartyEvent_ChangeExternalContactMsgAuditAsync(\n                                RequestMessage as RequestMessageEvent_Change_ExternalContact_MsgAudit);\n                        default:\n                            throw new UnknownRequestMsgTypeException(\"未知的外部联系人事件Event.CHANGE_EXTERNAL_CONTACT下属请求信息\",\n                                null);\n                    }\n                }\n                default:\n                    throw new UnknownRequestMsgTypeException(\"未知的InfoType请求类型\", null);\n            }\n        }\n\n        protected virtual async Task<string> OnThirdPartyEvent_Change_ContactAsync(\n            RequestMessageInfo_Change_Contact thirdPartyInfo)\n        {\n            return await Task.FromResult(OnThirdPartyEvent_Change_Contact(thirdPartyInfo)).ConfigureAwait(false);\n        }\n\n        protected virtual async Task<string> OnThirdPartyEvent_Register_CorpAsync(\n            RequestMessager_Register_Corp thirdPartyInfo)\n        {\n            return await Task.FromResult(OnThirdPartyEvent_Register_Corp(thirdPartyInfo)).ConfigureAwait(false);\n        }\n\n        [Obsolete(\"请使用修复拼写之后的方法:OnThirdPartyEvent_Register_CorpAsync\", true)]\n        protected virtual Task<string> OnThirdPartyEvent_REGISTER_CORPAsync(\n            RequestMessager_Register_Corp thirdPartyInfo)","sourceCodeStart":1251,"sourceCodeEnd":1287,"githubUrl":"https://github.com/JeffreySu/WeiXinMPSDK/blob/be573f6f94bdbf718dd5f6cdecb137fbc7ff651e/src/Senparc.Weixin.Work/Senparc.Weixin.Work/MessageHandlers/Async/WorkMessageHandler.Async.cs#L1251-L1287","documentation":"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.","triggerScenarios":"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.","commonSituations":"Suite apps whose callback URL receives events for features the library predates; WeCom API additions (new InfoType values); misconfigured suite callback URL scope.","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"],"exampleFix":"// before\nvar result = await messageHandler.BuildResponseMessageAsync();\n// after\ntry { var result = await messageHandler.BuildResponseMessageAsync(); }\ncatch (UnknownRequestMsgTypeException ex) { _logger.LogWarning(ex, \"Unhandled suite InfoType\"); return Content(\"success\"); }","handlingStrategy":"try-catch","validationCode":"if (!Enum.IsDefined(typeof(InfoType), thirdPartyInfo.InfoType)) { return \"success\"; }","typeGuard":"bool IsKnownInfoType(RequestMessageInfo_Base info) => Enum.IsDefined(typeof(InfoType), info.InfoType);","tryCatchPattern":"try { result = await handler.BuildResponseMessageAsync(); } catch (UnknownRequestMsgTypeException ex) { _logger.LogWarning(ex, \"Unhandled InfoType: {InfoType}\", info?.InfoType); return Content(\"success\"); }","preventionTips":["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"],"tags":["wechat-work","third-party-suite","infotype","unknown-event"],"backgroundTag":"unsupported-enum-value","analyzedSha":"be573f6f94bdbf718dd5f6cdecb137fbc7ff651e","analyzedAt":"2026-09-12T10:01:50.733Z","contentChangedAt":"2026-09-12T10:01:50.733Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}