Skip to content

Mensagens recebidas via API Meta com remoteJid trocado #2407

Description

@jhonyrsy

Welcome!

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

What did you do?

Eu utilizo Evolution API 2.3.7 e Chatwoot 4.1 e ja algum tempo estamos notando mensagens nas conversas no chatwoot que não tem relação com aquele cliente, então na ultima vez que encontrei recolhi o log da instancia da evolution e aconteceu o seguinte.

A mensagem foi tratada com o remotejid do cliente trocado, a mensagem chegou da meta com o remotejid correto, porem na hora de realizar o tratamento a evolution colocou a mensagem no remotejid de outro cliente.

segue log retirado da evolution da recepção da mensagem , só ocultei dados de clientes, mas acredito que é possivel notar que comparando o id WAMID recebido da mensagem da API da meta a que a Evolution tratou o remotejid não é o mesmo referente ao from

[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [string] Contenido recibido en eventHandler:
[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [string] {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "551xxxxxxx",
"phone_number_id": "698xxxxxxxxx"
},
"contacts": [
{
"profile": {
"name": "🌟"
},
"wa_id": "xxxx9576"
}
],
"messages": [
{
"from": "xxxx9576",
"id": "wamid.HBgNNTUxMTk5NzQ4OTU3NhUCABIYIEVCQkQ3NjI22dlotrG5jKBNDhEOTg5MEIxNUE4QzNBAA==",
"timestamp": "1755021194",
"text": {
"body": "8"
},
"type": "text"
}
]
}
[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [string] Tipo de mensaje recibido: text
[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [object]
{
key: {
id: 'wamid.HBgNNTUxMTk5NzQ4OTU3NhUCABIYIEVCQkQ3NjI22dlotrG5jKBNDhEOTg5MEIxNUE4QzNBAA==',
remoteJid: 'xxx04222@s.whatsapp.net',
fromMe: false
},
pushName: '🌟',
message: { conversation: '8' },
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1755021194,
source: 'unknown',
instanceId: 'xxxxxxxxxxxx'
}
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:16 VERBOSE [ChatwootService] [string] --- Start createConversation ---
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:16 VERBOSE [ChatwootService] [string] Instance: {"instanceName":"NomeInstancia","instanceId":"xxxxxxxxxxxx"}
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:16 VERBOSE [ChatwootService] [string] Found conversation to: xxx04222@s.whatsapp.net, conversation ID: 4681
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheEngine] [string] RedisCache initialized for Re
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheService] [string] cacheservice created using cache engine: Xt
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheEngine] [string] RedisCache initialized for Re
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheService] [string] cacheservice created using cache engine: Xt
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:18 VERBOSE [CacheEngine] [string] RedisCache initialized for Re
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:18 VERBOSE [CacheService] [string] cacheservice created using cache engine: Xt

What did you expect?

a entrega da mensagem no chatwoot seja realizada para o mesmo remetente recebido no json da API Cloud.
Conforme mostrado acima a mensagem foi recebida com um From e registrado com outro remoteJid na evolution e chatwoot

What did you observe instead of what you expected?

Que isso acontece não muito frequente , mas ocorre tanto com mensagens de texto como arquivos.

Screenshots/Videos

No response

Which version of the API are you using?

2.3.7

What is your environment?

Windows

Other environment specifications

VPS 6 CPU e 12,5Gb RAM

If applicable, paste the log output

[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [string] Contenido recibido en eventHandler:
[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [string] {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "551xxxxxxx",
"phone_number_id": "698xxxxxxxxx"
},
"contacts": [
{
"profile": {
"name": "🌟"
},
"wa_id": "xxxx9576"
}
],
"messages": [
{
"from": "xxxx9576",
"id": "wamid.HBgNNTUxMTk5NzQ4OTU3NhUCABIYIEVCQkQ3NjI22dlotrG5jKBNDhEOTg5MEIxNUE4QzNBAA==",
"timestamp": "1755021194",
"text": {
"body": "8"
},
"type": "text"
}
]
}
[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [string] Tipo de mensaje recibido: text
[Evolution API] [NomeInstancia] v2.3.7 199 - Tue Aug 12 2025 14:53:15 LOG [ChannelStartupService] [object]
{
key: {
id: 'wamid.HBgNNTUxMTk5NzQ4OTU3NhUCABIYIEVCQkQ3NjI22dlotrG5jKBNDhEOTg5MEIxNUE4QzNBAA==',
remoteJid: 'xxx04222@s.whatsapp.net',
fromMe: false
},
pushName: '🌟',
message: { conversation: '8' },
contextInfo: undefined,
messageType: 'conversation',
messageTimestamp: 1755021194,
source: 'unknown',
instanceId: 'xxxxxxxxxxxx'
}
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:16 VERBOSE [ChatwootService] [string] --- Start createConversation ---
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:16 VERBOSE [ChatwootService] [string] Instance: {"instanceName":"NomeInstancia","instanceId":"xxxxxxxxxxxx"}
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:16 VERBOSE [ChatwootService] [string] Found conversation to: xxx04222@s.whatsapp.net, conversation ID: 4681
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheEngine] [string] RedisCache initialized for Re
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheService] [string] cacheservice created using cache engine: Xt
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheEngine] [string] RedisCache initialized for Re
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:17 VERBOSE [CacheService] [string] cacheservice created using cache engine: Xt
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:18 VERBOSE [CacheEngine] [string] RedisCache initialized for Re
[Evolution API] v2.3.7 199 - Tue Aug 12 2025 14:53:18 VERBOSE [CacheService] [string] cacheservice created using cache engine: Xt

Additional Notes

Note no log que comparando o id wamid a mensagem esta sendo entregue para o remetente diferente do from recebido pela meta. O arquivo foi editado para não exibir dados reais do cliente, porem o log original está armazenado na minha maquina.

Activity

  1. fgalmeida commented on Mar 9, 2026

    @fgalmeida

    Estou enfrentando exatamente o mesmo problema na versão 2.3.7. Este é um bug crítico, pois está causando vazamento de mensagens entre diferentes contatos (leads).

  2. DavidsonGomes commented on May 19, 2026

    @DavidsonGomes
    Member

    Olá @jhonyrsy, obrigado pelo report extremamente detalhado — o log foi fundamental para diagnosticar.

    Diagnóstico

    Confirmamos a root cause: o messageHandle em whatsapp.business.service.ts estava usando this.phoneNumber (estado de instância compartilhado entre todos os webhooks da mesma instância Evolution) em vez de derivar o remoteJid por mensagem. Em rajada de webhooks da Cloud API:

    1. Webhook A chega para cliente X → this.phoneNumber = X
    2. Webhook B chega para cliente Y → this.phoneNumber = Y
    3. Webhook A continua processando e usa this.phoneNumber (agora Y) como remoteJid
    4. Mensagem do cliente X cai na conversa do cliente Y — vazamento de dados

    Fixes mergeados

    O bug foi corrigido em duas PRs:

    Ambas as PRs estão na branch develop e serão liberadas na próxima release (2.4.0 GA ou backport para 2.3.8 se priorizado).

    Recomendação

    Por favor teste na 2.4.0-rc2 (pre-release atual, lançada em 17/05/2026) e confirme se o vazamento parou de ocorrer. Se ainda reproduzir, reabra esta issue com novo log mostrando from na mensagem Meta vs remoteJid persistido — qualquer caminho residual que escapou dos fixes acima é P0 e merece um terceiro patch.

    Fechando como resolvido pelos fixes acima. Obrigado novamente — esse foi um bug crítico de vazamento de dados entre tenants e o seu report ajudou a fechar a janela.

    cc @fgalmeida (você reportou o mesmo na thread) — por favor também valide na 2.4.0-rc2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions