{"record":{"id":"a3f177d76b639bba","repo":"Tencent/WeKnora","slug":"wecom-bot-adapter-does-not-support-webhook-callbac","errorCode":null,"errorMessage":"WeCom bot adapter does not support webhook callbacks","messagePattern":"WeCom bot adapter does not support webhook callbacks","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/im/wecom/ws_adapter.go","lineNumber":42,"sourceCode":"// WSAdapter implements im.Adapter and im.StreamSender for WeCom in WebSocket\n// (long connection) mode. It delegates to the WebSocket LongConnClient.\n// The webhook methods (VerifyCallback, ParseCallback, HandleURLVerification) are no-ops\n// since messages arrive via WebSocket, not HTTP.\ntype WSAdapter struct {\n\tclient *LongConnClient\n}\n\n// NewWSAdapter creates an adapter backed by a WeCom long connection client.\nfunc NewWSAdapter(client *LongConnClient) *WSAdapter {\n\treturn &WSAdapter{client: client}\n}\n\nfunc (a *WSAdapter) Platform() im.Platform {\n\treturn im.PlatformWeCom\n}\n\nfunc (a *WSAdapter) VerifyCallback(c *gin.Context) error {\n\treturn fmt.Errorf(\"WeCom bot adapter does not support webhook callbacks\")\n}\n\nfunc (a *WSAdapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error) {\n\treturn nil, fmt.Errorf(\"WeCom bot adapter does not support webhook callbacks\")\n}\n\nfunc (a *WSAdapter) HandleURLVerification(c *gin.Context) bool {\n\treturn false\n}\n\nfunc (a *WSAdapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, reply *im.ReplyMessage) error {\n\treturn a.client.SendReply(ctx, incoming, reply)\n}\n\n// ── StreamSender implementation ──\n\nfunc (a *WSAdapter) StartStream(ctx context.Context, incoming *im.IncomingMessage) (string, error) {\n\treturn a.client.StartStream(ctx, incoming)","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/im/wecom/ws_adapter.go#L24-L60","documentation":"The WeCom bot WebSocket adapter (WSAdapter) implements the im.Adapter interface, which requires VerifyCallback. Because this adapter receives messages over a persistent WebSocket connection rather than an HTTP webhook, it cannot verify webhook callbacks and always returns this error. It is a deliberate 'unsupported operation' stub, not a transient failure.","triggerScenarios":"Calling VerifyCallback on a *im.WSAdapter obtained from the WeCom bot adapter, typically from a shared HTTP webhook route that dispatches to adapters generically.","commonSituations":"Reusing a webhook handler built for the WeCom corp-app (HTTP callback) adapter or another IM platform and pointing it at the WeCom bot WS adapter; registering the WS adapter in an HTTP callback router; assuming all Platform() values support webhook verification.","solutions":["Do not route webhook verification to the WS adapter; WeCom bot messages arrive over WebSocket, so remove VerifyCallback handling from its request path.","Register the WS adapter only in the WebSocket message loop and keep webhook routes bound to adapters that implement callback verification (e.g. the corp-app HTTP adapter).","Use HandleURLVerification / VerifyCallback only on adapters whose transport is HTTP; branch on adapter capabilities before calling."],"exampleFix":"// before\nerr := wsAdapter.VerifyCallback(c) // always fails\n// after\nif _, ok := adapter.(im.WebhookVerifier); ok {\n    err = adapter.VerifyCallback(c)\n} else {\n    // handle via WebSocket path\n}","handlingStrategy":"validation","validationCode":"if verifier, ok := adapter.(interface{ VerifyCallback(*gin.Context) error }); ok && supportsWebhook(adapter.Platform()) {\n    err = verifier.VerifyCallback(c)\n}","typeGuard":"func supportsWebhookVerify(a im.Adapter) bool {\n    _, ok := a.(interface{ VerifyCallback(*gin.Context) error });\n    return ok && !isWecomWSAdapter(a)\n}","tryCatchPattern":"if err := adapter.VerifyCallback(c); err != nil && strings.Contains(err.Error(), \"does not support webhook callbacks\") {\n    c.Status(http.StatusNotImplemented)\n    return\n}","preventionTips":["Route WeCom bot traffic through the WebSocket handler, never webhook middleware.","Only bind HTTP callback routes to adapters with HTTP transports.","Check adapter capabilities before invoking interface methods that may be stubs."],"tags":["wecom","websocket","unsupported-operation","im-adapter"],"backgroundTag":"unsupported-callback-transport","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}