evolution-api icon indicating copy to clipboard operation
evolution-api copied to clipboard

Outbound messages to personal contacts via PN JID never delivered on LID-migrated account — @lid addressing works, @s.whatsapp.net silently fails

Open agungpmbd opened this issue 4 months ago • 4 comments

Welcome!

  • [x] Yes, I have searched for similar issues on GitHub and found none.

What did you do?

On a WhatsApp account fully migrated to LID addressing (inbound messages arrive with addressingMode: "lid", remoteJid: <id>@lid, remoteJidAlt: <phone>@s.whatsapp.net), I sent outbound messages to personal contacts using the standard endpoint: POST /message/sendText/{instance} {"number": "62XXXXXXXXXX", "text": "test"}

To isolate the problem I systematically tested:

  1. Multiple recipient numbers addressed by phone number (PN) — via API directly and via Chatwoot integration replies
  2. The same recipient addressed as <lid>@lid — e.g. {"number": "1584XXXXXXXXXX@lid"}
  3. Group messages (@g.us) — via API and Chatwoot
  4. Three versions: v2.3.7 → 2.4.0-rc2 → homolog (all evoapicloud images), including builds containing fix #2544
  5. Full session re-pair on homolog: logout, deleted the Session row from Postgres, fresh QR pairing — to rule out stale session state
  6. POST /chat/whatsappNumbers on the affected numbers to look for a PN→LID resolution path

What did you expect?

Messages sent to {"number": "<phone>"} should be delivered to the recipient's device. The send path should resolve PN → LID before dispatching (the mapping already exists internally — OnWhatsappCache stores the lid, and inbound events carry both JIDs), the same way the official WhatsApp client on the very same account does.

What did you observe instead of what you expected?

Path v2.3.7 2.4.0-rc2 homolog homolog + fresh session
Inbound (personal & group) ✅ ✅ ✅ ✅
Outbound group (@g.us) ✅ ✅ ✅ ✅
Outbound personal — PN (@s.whatsapp.net) ❌ ❌ ❌ ❌
Outbound personal — @lid ✅ (not retested) (not retested) (not retested)

For the PN path: the API returns HTTP 201 with status: "PENDING", no errors in logs (LOG_LEVEL=CLIENT,ERROR,INFO), the status never progresses past PENDING, and the message never arrives on the recipient's device. Consistent across all recipient numbers tested.

Sending to the exact same contact as <lid>@lid is delivered successfully.

POST /chat/whatsappNumbers returns exists: true for these undeliverable numbers and does not include any lid field — so there is also no public API path to resolve PN → LID as a workaround.

Impact: Chatwoot integration replies to personal contacts are 100% broken, since Chatwoot always dispatches to the PN identifier. Replying from a LID-keyed conversation works, which creates split-brain duplicate contacts (inbound lands on the PN contact, outbound only works from the LID contact).

Screenshots/Videos

No response

Which version of the API are you using?

Reproduced on: 2.3.7, 2.4.0 (image tag 2.4.0-rc2), 2.4.0 (image tag homolog, whatsappWebVersion 2.3000.1042742319)

What is your environment?

Windows

Other environment specifications

  • Docker Compose (images: evoapicloud/evolution-api), Ubuntu 24.04 VPS
  • Integration: Baileys (WHATSAPP-BAILEYS)
  • Database: PostgreSQL 15 | Cache: Redis (alpine)
  • Chatwoot integration enabled (Chatwoot installed natively on the same host)
  • License activated (community tier) on 2.4.0 builds

If applicable, paste the log output

Send request response (PN path — accepted, never delivered):

{"key":{"remoteJid":"[email protected]","fromMe":true,"id":"3EB0..."},
"pushName":"Você","status":"PENDING","message":{"conversation":"test"},
"messageType":"conversation","source":"web"}

No ERROR entries appear in the container logs for these sends; the transaction is treated as completed. Inbound event on the same account showing the LID pair:

"key": {
  "remoteJid": "1584XXXXXXXXXX@lid",
  "remoteJidAlt": "[email protected]",
  "fromMe": false,
  "addressingMode": "lid"
}

Additional Notes

  • The official WhatsApp app logged into the same account sends to these contacts normally, so the account itself is healthy — this is a send-path addressing issue.
  • Fix #2544 (bypass onWhatsApp validation for @lid) is confirmed present in the tested builds and unblocks sending to @lid JIDs, but does not add PN → LID resolution before sending — which appears to be the missing piece.
  • Suggested fix: in the send path, consult OnWhatsappCache / contact store for a known lid mapping of the target PN and dispatch to the @lid JID when present. Exposing the lid in the /chat/whatsappNumbers response would also enable client-side workarounds.
  • Happy to run diagnostic builds or provide further logs privately.

agungpmbd avatar Jul 07 '26 22:07 agungpmbd

lid_fix_v2.zip Man, I ran into the same headache with the LID migration issue. It looks like the outbound resolver was totally skipping the OnWhatsappCache lookup when hitting the PN endpoint. I put together a quick patch that forces the JID mapping during the dispatch phase so it actually hits the right target.

⚠️ Warning to others: do not download the zip above — unsolicited zip 'fixes' from new accounts are a known malware pattern on GitHub. Legitimate patches come as PRs or reviewable diffs.

agungpmbd avatar Jul 07 '26 22:07 agungpmbd

[Evolution API] [Hefestus_1] v2.3.7 163 - Thu Jul 09 2026 15:24:45 VERBOSE [ChannelStartupService] [string] Sending message to [email protected] Closing session: SessionEntry { _chains: { XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: { chainKey: [Object], chainType: 1, messageKeys: {} } }, registrationId: XXXXXXXX, currentRatchet: { ephemeralKeyPair: { pubKey: <Buffer 05 a7 6b 34 9f 47 b6 29 41 c4 a9 b4 cf b7 ca ef 39 37 d4 62 2b 39 76 93 29 b6 22 27 71 86 d4 81 38>, privKey: <Buffer 60 40 7a de 86 51 c4 84 4f 36 e9 fe d0 f7 02 2d 9e d5 01 00 66 4e c6 49 01 1a 4e 60 c6 38 ad 7b> }, lastRemoteEphemeralKey: <Buffer 05 18 64 d9 67 49 c9 64 14 35 18 b7 06 0b c8 23 66 5f ca a8 05 b7 fb a9 17 d2 17 28 b8 03 2a 00 09>, previousCounter: 0, rootKey: <Buffer 70 8e de 81 0a 91 92 2f 28 c6 1e 1e e1 92 cf 1d 91 b4 85 2a 5e a4 0a 28 7e 3e 0b 03 ae 5e cb f9> }, indexInfo: { baseKey: <Buffer 05 0b d7 1f d0 4c fc 9c 02 d5 74 f1 ea ab 46 3a dc 21 dd af 0e b9 e0 ce fc a5 78 5e 23 62 f4 12 46>, baseKeyType: 1, closed: -1, used: 1783621455974, created: 1783621455974, remoteIdentityKey: <Buffer 05 49 75 75 88 fa a6 d0 3b 0a 5a b6 f1 14 fd 08 e8 cd f2 48 07 91 c4 71 80 5a f6 f7 39 eb d5 c5 54> }, pendingPreKey: { signedKeyId: 5695820, baseKey: <Buffer 05 0b d7 1f d0 4c fc 9c 02 d5 74 f1 ea ab 46 3a dc 21 dd af 0e b9 e0 ce fc a5 78 5e 23 62 f4 12 46>, preKeyId: 1855152 } } Closing session: SessionEntry { _chains: { 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX': { chainKey: [Object], chainType: 1, messageKeys: {} } }, registrationId: 1152105870, currentRatchet: { ephemeralKeyPair: { pubKey: <Buffer 05 49 41 08 ac 9e 0c f5 1d 6e 01 d2 2b d1 42 c3 cf b8 c4 75 ea fe be e0 a5 49 9a 46 7b 4f f2 dc 00>, privKey: <Buffer f0 4d 2c d9 4b ef ad 97 1b ed 6c 82 ef 2e 97 29 e3 2d f7 00 40 d1 70 fa 1d 97 c3 af 88 22 52 68> }, lastRemoteEphemeralKey: <Buffer 05 2d d5 c3 9d 52 f7 73 8f ed ec 57 80 8d a4 8b d2 e2 75 dd e0 93 17 11 91 cc 2a 0b da 5d 35 a5 36>, previousCounter: 0, rootKey: <Buffer cb 95 ff e0 88 ab 8a 14 6b 48 55 cf e7 70 83 9d 9b c3 97 8b e4 5a d6 59 01 e5 c4 84 e4 d8 cd e0> }, indexInfo: { baseKey: <Buffer 05 93 6e c2 90 d2 4f cb f3 88 95 53 27 d8 ab 15 f3 81 20 8b 35 04 8d 2c c8 8d ee c2 8c b7 03 9b 5c>, baseKeyType: 1, closed: -1, used: 1783621455979, created: 1783621455979, remoteIdentityKey: <Buffer 05 e6 2a dc c6 bf 67 de 35 3f 61 48 f8 a7 3d 53 87 a5 86 5e af e9 8f f4 89 cc 30 e0 19 b1 83 89 19> }, pendingPreKey: { signedKeyId: 3514300, baseKey: <Buffer 05 93 6e c2 90 d2 4f cb f3 88 95 53 27 d8 ab 15 f3 81 20 8b 35 04 8d 2c c8 8d ee c2 8c b7 03 9b 5c>, preKeyId: 3200555 } } [Evolution API] [Hefestus_1] v2.3.7 163 - Thu Jul 09 2026 15:24:46 VERBOSE [ChannelStartupService] [object]
WebMessageInfo { messageStubParameters: [], labels: [], userReceipt: [], reactions: [], pollUpdates: [], eventResponses: [], statusMentions: [], messageAddOns: [], statusMentionSources: [], supportAiCitations: [], key: MessageKey { remoteJid: '[email protected]', fromMe: true, id: 'XXXXXXXXXXXXXXXX' }, message: Message { extendedTextMessage: { text: 'teste', contextInfo: [Object] } }, messageTimestamp: 1783621485, status: 1 }

[Evolution API] [Hefestus_1] v2.3.7 163 - Thu Jul 09 2026 15:24:46 VERBOSE [ChannelStartupService] [string] Update messages [ { "key": { "remoteJid": "[email protected]", "fromMe": true, "id": "XXXXXXXXXXXXXXXX" }, "update": { "status": 0, "messageStubParameters": [ "463" ] } } ] CACHE: { cached: null, updateKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', messageTimestamp: undefined, secondsSinceEpoch: 1783621486 }

I really don't know if this error is related, but I send the message, it returned as completed, but anything is being returned in the whatsapp chat, only in the API private chat. It's receiving the message and sending for my chatbot, but It ain't returning anything. The chatbot gives a response, send it to evolution, but the api simply don't send it to the user in the whatsapp chat. Stack:

  • Evolution Host: Hostinger/Easypanel
  • Chatbot: NodeJs (Fastify) + Mastra
  • Queue: Inngest

Jao16905 avatar Jul 09 '26 18:07 Jao16905

We're also affected by this issue and want to add a data point that may be useful: in addition to the silent-failure-on-send behavior described above, we're seeing what looks like a temporary WhatsApp-side pairing/linking block on our LID-migrated instance (Evolution API v2.3.7, Baileys integration).

Symptoms:

  • Multiple stream:error events in our container logs over the past few days, with fullErrorNode.attrs.code alternating between 515 (stream restart required) and 503 (service unavailable).
  • After disconnecting the instance and requesting new QR codes, the WhatsApp app fails to pair with "couldn't link device, try again later" — reproduced on two different physical phones on the same account, so it doesn't seem to be a device-side issue.
  • Server-side, no connection.update event is ever logged for these failed attempts — the QR simply expires and a new one is generated (we saw the internal qrcodeCount counter climb to 16+ in a single session), suggesting the phone/WhatsApp backend is rejecting the link attempt before it reaches our instance at all.

We suspect this may be a WhatsApp-side anti-abuse rate limit triggered by repeated pairing attempts on an already-LID-migrated number, possibly compounding the addressing bug described in this issue. Wanted to flag it in case others hit the same wall while trying to re-pair as a workaround — worth waiting several hours between attempts rather than retrying immediately.

Happy to share full log excerpts if useful for diagnosis.

leozitto26-ops avatar Aug 07 '26 11:08 leozitto26-ops

Confirming this on v2.4.0 (evoapicloud/evolution-api:2.4.0-rc2, Baileys, Postgres), and adding a data point that may point at the root cause: the failure correlates with when the instance was paired, not with the account or the number.

Two instances, same server, same minute

instance paired outbound addressing produced by Baileys result
A (established) 2026-07-16 <id>@lid + addressingMode: "lid" SERVER_ACK → delivered
B (fresh pair) 2026-08-17 <phone>@s.whatsapp.net, no addressingMode PENDING forever

Same Evolution process, same API call shape, same recipient. On instance A a single sendText produces two rows in Message: the legacy @s.whatsapp.net one stuck at PENDING, and one microsecond later the @lid one with SERVER_ACK — i.e. the resolver runs and the LID dispatch is what actually delivers. On instance B only the legacy row is ever created: the PN → LID resolution never happens.

The mapping exists on B and is still not used

Instance B receives from the same contact correctly, arriving as <id>@lid with addressingMode: "lid" — so the mapping is known to the session. Sending to that same contact immediately afterwards still emits @s.whatsapp.net and stalls.

Passing the LID explicitly is not a workaround: {"number": "<id>@lid"} is normalised back to <phone>@s.whatsapp.net before dispatch (in one attempt it was rewritten to a different phone number entirely).

What we ruled out

Two different accounts (one bought new the day before, zero sending history); two physical handsets; v2.3.7 and v2.4.0; six re-pairings; instance recreated from scratch; licence activated; volumes of <15 msg/day. Sending from the handset works on every account, including the ones whose companion cannot send — so this is not an account restriction.

Country correlation is coincidental in our case and worth flagging so others don't chase it: our working instance is a BR account paired in July, our failing ones are PT accounts paired this week. Pairing date, not region.

Possible reading

The PN→LID map looks like it is populated during the initial contact/history sync and consulted on dispatch. Instances paired after the account's LID migration appear to start with that map empty for the send path, and syncFullHistory: false (default) may mean it is never backfilled — while inbound continues to work because the LID arrives on the wire.

Happy to run any diagnostic query against Message/Contact on both instances if it helps narrow it down.


⚠️ Note for anyone landing here: please don't download the lid_fix_v2.zip posted above. Unsolicited zip "fixes" are a known malware vector; legitimate patches arrive as reviewable PRs or diffs.

ConstruAgil-Steel avatar Aug 17 '26 15:08 ConstruAgil-Steel