Chatbot integrations (Typebot/OpenAI/Dify) process the same key.id twice on device redelivery — same root cause as #2675, different code path
维护者通常 8 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Begin in whatsapp.baileys.service.ts at the messages.upsert handler and trace the call to chatbotController.emit(...), using the described duplicate key.id records as the reproduction. Done means one redelivered message is not dispatched twice on the generic chatbot path, including Typebot, OpenAI, Dify, EvolutionBot, and Chatwoot.
由索引模型根据 Issue 内容生成。
描述
Bug Description
Same root cause as #2675 / PR #2716 ("live path has no idempotency check on key.id redelivery"), but manifesting through the generic chatbot integration path (Typebot in my case — the dispatch point is shared with OpenAI/Dify/EvolutionBot, so likely affects those too), not just Chatwoot.
When a sender device redelivers the same WhatsApp message (identical key.id, same messageTimestamp), the messages.upsert handler processes it a second time and calls chatbotController.emit(...) again for the same message. If the bot session is at that moment awaiting a user reply (e.g. a button-click input step), the duplicate gets consumed as if it were the real answer — causing the flow to end prematurely, or in rarer timing windows (duplicate arriving mid-way through a slow downstream call), a second parallel bot session gets created for the same contact.
Evidence
Two rows in the Message table with the exact same WhatsApp key.id and messageTimestamp, inserted as separate records:
Row 1: key = {"id":"AC38A38C28E1A42533C197A0DF755C00","fromMe":false,"remoteJid":"<redacted>@lid"}, messageTimestamp=1790089374
Row 2: key = {"id":"AC38A38C28E1A42533C197A0DF755C00","fromMe":false,"remoteJid":"<redacted>@lid"}, messageTimestamp=1790089374
Confirmed via the Typebot side too: the bot's AnswerV2 log shows the trigger keyword itself (e.g. "pdfreceitas") captured as the answer to an unrelated later input block, ~50-200ms after the flow started — far too fast to be a real user action, consistent with the redelivery landing while the session was mid-flow.
All affected messages in my case have addressingMode: "lid" — possibly incidental (maybe @lid contacts are more prone to whatever triggers the client-side resend loop mentioned in #2675), but worth checking since #2716 also touches @lid-related edge cases (see #2718 too).
Environment
- Evolution API:
2.4.0-rc2 - Typebot:
3.19.0(baptistearno/typebot-builder/typebot-viewer) - Deployment: Docker Swarm (separate services for
evolution-api,postgres,redis,typebot-builder,typebot-viewer), Baileys channel - Chatbot integration: native Typebot integration (
/typebot/create, keyword trigger)
Suggested fix
#2716 adds the key.id-based idempotency check (via getExistingSourceIds/cache) specifically inside the Chatwoot code path. Since the redelivery happens upstream of any specific integration — at the messages.upsert handler in whatsapp.baileys.service.ts, right where chatbotController.emit(...) is called — placing an equivalent dedup check there (or in chatbotController.emit itself) would cover Typebot/OpenAI/Dify/EvolutionBot/Chatwoot all at once, instead of needing the same fix re-implemented per integration.
Happy to test a patch against this setup if useful, or provide more logs.
- 主要语言
- TypeScript
- 星标
- 9.8k
- 派生
- 7.3k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
evolution-foundation/evolution-api 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
evolution-foundation/evolution-api#2723 ·
维护者通常 8 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
evolution-foundation/evolution-api#2704 ·
维护者通常 8 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
evolution-foundation/evolution-api#2702 · 1 条评论 · 2 个 reaction ·
维护者通常 8 天内回复
-
[BUG] Cloud API: a single unknown wamid in a `statuses` batch silently drops the whole batch (`return` instead of `continue`)可能已有人在做 @vin1i 于 45 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
evolution-foundation/evolution-api#2700 · 1 条评论 ·
维护者通常 8 天内回复
-
[BUG] Chatwoot integration duplicates messages when a device re-delivers the same key.id — getExistingSourceIds exists but is never called on the live path可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
evolution-foundation/evolution-api#2675 ·
维护者通常 8 天内回复
查看 evolution-foundation/evolution-api 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
db-ux-design-system/core-web#8461 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Cannot run an integration on windows when power shell is selected as the default profile terminal未关闭Priority/Blocker Type/Bug
难度 2/5 1-3 小时 新手友好度 76/100
wso2/product-integrator#2767 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
-
severity:low
难度 1/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复