{"record":{"id":"757dc387cf0fd739","repo":"Tencent/WeKnora","slug":"wechat-adapter-does-not-support-webhook-callbacks","errorCode":null,"errorMessage":"WeChat adapter does not support webhook callbacks","messagePattern":"WeChat adapter does not support webhook callbacks","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/im/wechat/adapter.go","lineNumber":86,"sourceCode":"\tbotToken   string\n\tilinkBotID string\n}\n\n// NewAdapter creates a new WeChat iLink adapter.\nfunc NewAdapter(botToken, ilinkBotID string) *Adapter {\n\treturn &Adapter{\n\t\tbotToken:   botToken,\n\t\tilinkBotID: ilinkBotID,\n\t}\n}\n\nfunc (a *Adapter) Platform() im.Platform {\n\treturn im.PlatformWeChat\n}\n\n// VerifyCallback is not supported — WeChat iLink uses long-polling, not webhooks.\nfunc (a *Adapter) VerifyCallback(c *gin.Context) error {\n\treturn fmt.Errorf(\"WeChat adapter does not support webhook callbacks\")\n}\n\n// ParseCallback is not supported — messages arrive via long-polling.\nfunc (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {\n\treturn nil, fmt.Errorf(\"WeChat adapter does not support webhook callbacks\")\n}\n\n// HandleURLVerification is not applicable for WeChat.\nfunc (a *Adapter) HandleURLVerification(c *gin.Context) bool {\n\treturn false\n}\n\n// SendReply sends a text reply to the user via iLink /ilink/bot/sendmessage API.\nfunc (a *Adapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, reply *im.ReplyMessage) error {\n\tcontextToken := \"\"\n\tif incoming.Extra != nil {\n\t\tcontextToken = incoming.Extra[\"context_token\"]\n\t}","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/im/wechat/adapter.go#L68-L104","documentation":"The WeChat (iLink) adapter communicates exclusively via long-polling, so its VerifyCallback method intentionally returns a fixed error stating that webhook callbacks are unsupported. Hitting this means code is treating the WeChat adapter as if it had a webhook-based platform like Slack or WeCom.","triggerScenarios":"Calling Adapter.VerifyCallback with a gin.Context on a WeChat channel — typically from a generic HTTP handler that routes inbound webhook requests to the channel's adapter without checking platform capability.","commonSituations":"Registering a shared /webhooks/:platform route for all IM platforms; switching a channel's platform from Slack to WeChat without changing the callback wiring; writing integration tests that assume every adapter implements webhook verification.","solutions":["Do not route webhook requests to the WeChat adapter; rely on its long-poll client (NewLongPollClient) for inbound messages.","Add a capability check (e.g. platform == im.PlatformWeChat) before calling VerifyCallback and skip/short-circuit for WeChat.","If webhook delivery is genuinely required, use the WeCom adapter instead, which supports callbacks."],"exampleFix":"// before\nif err := adapter.VerifyCallback(c); err != nil { ... }\n// after\nif platform == im.PlatformWeChat {\n    return // handled by long-polling; no webhook endpoint\n}\nif err := adapter.VerifyCallback(c); err != nil { ... }","handlingStrategy":"type-guard","validationCode":"// capability check before dispatching webhooks\nif ch.Platform == im.PlatformWeChat {\n    c.Status(http.StatusNoContent)\n    return // no webhook surface; long-polling handles messages\n}","typeGuard":"func supportsWebhooks(p im.Platform) bool {\n    return p != im.PlatformWeChat\n}","tryCatchPattern":"if err := adapter.VerifyCallback(c); err != nil {\n    if strings.Contains(err.Error(), \"does not support webhook callbacks\") {\n        c.Status(http.StatusNotImplemented)\n        return\n    }\n    c.String(http.StatusUnauthorized, \"verify failed\")\n}","preventionTips":["Route webhook HTTP traffic only to webhook-capable platforms (Slack, WeCom).","Encode adapter capabilities in an interface or capability method instead of relying on errors.","Add integration tests asserting WeChat inbound flow goes through the long-poll client."],"tags":["wechat","webhook","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}