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

fromMe audio from @lid contacts stored as message:null and never dispatched (2.4.0-rc2 / Baileys 7.0.0-rc.9)

Open igorgrillo opened this issue 6 months ago • 1 comments

Version

  • Evolution API: 2.4.0-rc2 (image evoapicloud/evolution-api:2.4.0-rc2)
  • Baileys: 7.0.0-rc.9 (shipped with 2.4.0-rc2)
  • Integration: Baileys (not Business API)

Summary

When the connected device sends an audio message from itself (fromMe: true) to a contact whose JID is @lid (multi-device / new LID addressing), Evolution stores message: null in the Message table and never dispatches the messages.upsert webhook. Inbound audio works fine. Outbound audio (fromMe) to @s.whatsapp.net contacts also works fine. The bug is specific to fromMe + @lid + audio carrying secretEncryptedMessage / messageContextInfo.

This is the underlying decryption failure behind several user reports — distinct from the remoteJid cosmetic issue tracked in #1872 (which is about JID format), and adjacent to #2550 (getBase64FromMediaMessage failing on iOS audio).

Expected behavior

messages.upsert event fires with the decrypted audioMessage payload, same as for any other outbound audio.

Actual behavior

  1. The phone sends the audio (delivered fine on WhatsApp).
  2. Postgres row is created in Message with:
    • key.fromMe = true
    • key.remoteJid ending in @lid
    • message = null
  3. No messages.upsert event is emitted (Webhook / RabbitMQ / WebSocket / SQS — all unified through eventManager.emit(), none fire).
  4. POST /chat/getBase64FromMediaMessage/{instance} for that messageId returns:
    TypeError: Cannot read properties of null (reading 'audioMessage')
    

Root cause

Baileys 7.0.0-rc.9 fails to decrypt secretEncryptedMessage (multi-device sync payload) when the peer is @lid. The unencrypted message object never materializes, so Evolution's repository writes null, and the event dispatcher early-returns before calling eventManager.emit.

Reproduction

  1. Run evoapicloud/evolution-api:2.4.0-rc2 against a fresh instance.
  2. Pair a phone via QR.
  3. From the paired phone itself (not the API), record and send an audio to a contact that resolves to @lid (typically contacts you haven't saved or that haven't whitelisted you).
  4. Watch the DB:
    SELECT key, "messageType", message IS NULL AS msg_is_null
    FROM \"Message\"
    ORDER BY \"messageTimestamp\" DESC LIMIT 5;
    
    The new row has msg_is_null = true.
  5. No webhook is delivered.

Repeat the same flow with a contact whose remoteJid ends in @s.whatsapp.net → audio dispatched normally. Repeat with inbound audio from @lid → also dispatched normally.

Fix verified

I patched Evolution 2.4.0-rc2 by overriding the Baileys dependency to 7.0.0-rc12 via a derived image:

FROM evoapicloud/evolution-api:2.4.0-rc2
RUN cd /evolution && npm install --no-save [email protected]

The relevant Baileys release notes:

  • 7.0.0-rc10 (2026-05-06): "LID<->PN mappings", "encryption failures handling", "patched fromMe in some scenarios", "multi-device sync rust app state"
  • 7.0.0-rc11: libsignal moved to npm
  • 7.0.0-rc12 (2026-05-20): security patch GHSA-qvv5-jq5g-4cgg

After the override, fromMe audio from @lid contacts decrypts correctly, message is populated, and messages.upsert fires.

Compatibility audit performed before the patch

  • Extracted all destructured imports + member accesses from dist/**/*.js: 96 distinct Baileys symbols used by Evolution.
  • All 96 are still exported by 7.0.0-rc12.
  • Symbols removed between rc.9 → rc12 (isJidUser, makeWALegacySocket, generateMessageID, useMultiFileAuthState): not used by Evolution dist code.
  • Full boot test against production Postgres+Redis (isolated schema): license activated, Prisma ON, WA module ON, zero errors/warnings.

Suggested action

Bump Baileys to 7.0.0-rc12 (or whatever ships ≥ rc10) in the next Evolution release. The override is a one-line package.json change and the dist code is fully compatible.

Related

  • #1872 — [META] @lid vs @jid handling umbrella (this is a deeper symptom)
  • #2550 — getBase64FromMediaMessage returns ephemeralMessage error with iOS audio (same message: null root cause for the fromMe LID case)
  • Baileys WhiskeySockets/Baileys#1692 — original LID encryption discussion

igorgrillo avatar May 21 '26 16:05 igorgrillo

Closing — won't pursue further. Thanks.

igorgrillo avatar May 21 '26 21:05 igorgrillo