Repository navigation
Conversation
Reviewer's GuideImplementationMake link preview generation conditional on an explicit
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts" line_range="2641" />
<code_context>
}
- const linkPreview = options?.linkPreview === false ? false : undefined;
+ const linkPreview = options?.linkPreview === true ? true : undefined;
let previewContext: any = undefined;
</code_context>
<issue_to_address>
**URL messages still generate previews**
When the caller omits `linkPreview` or passes `false` for a text message containing a URL, `linkPreview` becomes `undefined` and `sendMessage` forwards it to Baileys, whose default enables previews; URL messages still trigger preview generation and fail delivery, and explicit opt-outs are lost.
Set `linkPreview` to `false` unless the caller explicitly passes `true`, and forward that value to Baileys.
Also at `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:2642`.
</issue_to_address>
### Comment 2
<location path="src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts" line_range="2644" />
<code_context>
let previewContext: any = undefined;
- if (linkPreview !== false && (message as any)?.conversation) {
+ if (linkPreview === true && (message as any)?.conversation) {
previewContext = await this.generateLinkPreview((message as any).conversation);
}
</code_context>
<issue_to_address>
**Chatbot URL replies still fail**
When a chatbot integration sends a reply containing a URL, the chatbot adapters pass `linkPreview: true` for replies without an explicit preview request from the chatbot consumer, so `sendMessageWithTyping` still calls `generateLinkPreview()` and URL replies can remain undelivered.
Have chatbot integrations default to previews off and pass `true` only when their consumer explicitly opts in.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:2641, src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts:2644
|
|
||
| let previewContext: any = undefined; | ||
| if (linkPreview !== false && (message as any)?.conversation) { | ||
| if (linkPreview === true && (message as any)?.conversation) { |
There was a problem hiding this comment.
🟡 Medium · Chatbot URL replies still fail
When a chatbot integration sends a reply containing a URL, the chatbot adapters pass linkPreview: true for replies without an explicit preview request from the chatbot consumer, so sendMessageWithTyping still calls generateLinkPreview() and URL replies can remain undelivered.
Have chatbot integrations default to previews off and pass true only when their consumer explicitly opts in.
Prompt for AI agents
In `src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts` at line 2644:
**Chatbot URL replies still fail**
When a chatbot integration sends a reply containing a URL, the chatbot adapters pass `linkPreview: true` for replies without an explicit preview request from the chatbot consumer, so `sendMessageWithTyping` still calls `generateLinkPreview()` and URL replies can remain undelivered.
Have chatbot integrations default to previews off and pass `true` only when their consumer explicitly opts in.Link preview was enabled by default: it was only disabled when the caller passed linkPreview:false explicitly. On 2.4.0-rc2 (Baileys), the default path calls generateLinkPreview() for any message whose text contains a URL, and those messages fail to be delivered to the recipient (fixes evolution-foundation#2762). Invert the default so the preview is generated only when linkPreview:true is passed explicitly. Callers that still want the preview can send linkPreview:true. Co-Authored-By: Claude Code <noreply@anthropic.com>
873cf46 to
825b8da
Compare
|
Closing this. The actual cause of the delivery issue was the Baileys 7.0.0-rc.13 outbound bug (present in 2.4.0-rc2), which is fixed by moving to v2.3.8 / Baileys 7.0.0-rc.9 — not by the link preview default. This change (disabling preview by default) is a symptom workaround rather than a root-cause fix, so I'm withdrawing it. |
Summary
Fixes #2762.
On
2.4.0-rc2(Baileys) the link preview is enabled by default: text messages whose content contains a URL end up going through preview generation, and — on this version — those messages fail to be delivered to the recipient.What the bug looks like
POST /message/sendText/{instance}returnsstatus: "PENDING"with no error, but the message with a link never arrives.linkPreview: falsearrives normally.extendedTextMessagehas nomatchedText/title/description/ thumbnail.linkPreview) have no way to disable the preview, so every message containing a link is affected.Root cause
textMessagemapslinkPreviewtoundefinedunless the caller explicitly passesfalse:undefinedis then forwarded to Baileys (this.client.sendMessage(..., { linkPreview })). In Baileys'generateWAMessageContent(lib/Utils/messages.js),undefinedis not "no preview" — it triggers automatic preview generation:So the only value that actually disables the preview is
false. Setting the default toundefined(the current behavior) is what keeps every URL message on the broken preview path.How the fix works
The default is inverted to
false: the preview is generated only whenlinkPreview: trueis passed explicitly. When the field is omitted (the common case),falseis forwarded to Baileys, which skips preview generation and delivers the message normally. Callers that want the preview can still request it withlinkPreview: true.Testing
linkPreview: truepath is unchanged.2.4.0-rc2output (dist/api/integrations/channel/whatsapp/whatsapp.baileys.service.js): the minified default goes from...===!1?!1:void 0...(undefined) to...===!0?!0:!1...(false), so Baileys no longer auto-generates the preview for messages without an explicitlinkPreview: true.🤖 Generated with Claude Code