[BUG] msgCall quebra com TypeError quando quem liga chega como @lid, e o erro engole o webhook CALL do offer
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend-api-design
Research direction
Read src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts around lines 1886–1899 in tag 2.3.7, focusing on the call offer handler, LID mapping, sendMessage, and sendDataWebhook. Trace what happens when getPNForLID() returns undefined and check how an error affects the remaining event handlers. Done means an unmapped LID cannot suppress the CALL offer webhook or abort unrelated events, while the webhook retains the original caller JID.
Written by the indexing model from the issue text.
Description
Bem-vindo!
- Sim, pesquisei problemas semelhantes no GitHub e não encontrei nenhum.
O que você fez?
Tenho instâncias Baileys numa Evolution 2.3.7, algumas delas com recusa automática de chamada ligada:
{ "rejectCall": true, "msgCall": "📵 Desculpe, esse número não recebe chamadas; envie uma mensagem!" }
Comparando o que acontece quando alguém liga para essas instâncias, encontrei dois comportamentos diferentes, dependendo apenas do formato do JID de quem liga:
| Quem ligou chegou como | Chamada recusada | msgCall enviada |
|---|---|---|
5511xxxxxxxxx:[email protected] |
sim | sim |
2148301202187xx@lid |
sim | não — estoura TypeError |
O que você esperava?
Que a mensagem do msgCall fosse enviada em qualquer um dos dois casos, e que uma falha nesse envio não afetasse mais nada.
O que vc observou ao invés do que esperava?
Quando quem liga chega como @lid, a chamada é recusada (o servidor confirma com CB:ack, class: 'call', type: 'reject'), mas o envio da mensagem quebra:
[Evolution API] [<instancia>] v2.3.7 - ERROR [ChannelStartupService]
TypeError: Cannot destructure property 'user' of 'jidDecode(...)' as it is undefined.
at relayMessage (file:///evolution/node_modules/baileys/lib/Socket/messages-send.js:408:17)
at Object.sendMessage (file:///evolution/node_modules/baileys/lib/Socket/messages-send.js:957:23)
at async /evolution/dist/main.js:263:3482
Causa, em src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts (linhas 1886–1899 na tag 2.3.7):
if (settings?.rejectCall && call.status == 'offer') {
this.client.rejectCall(call.id, call.from);
}
if (settings?.msgCall?.trim().length > 0 && call.status == 'offer') {
if (call.from.endsWith('@lid')) {
call.from = await this.client.signalRepository.lidMapping.getPNForLID(call.from as string);
}
const msg = await this.client.sendMessage(call.from, { text: settings.msgCall });
this.client.ev.emit('messages.upsert', { messages: [msg], type: 'notify' });
}
this.sendDataWebhook(Events.CALL, call);
Quando o LID de quem liga ainda não tem mapeamento para telefone — caso comum de alguém que nunca conversou com o número —, getPNForLID() devolve undefined. O valor é escrito de volta em call.from, e o sendMessage(undefined, …) cai no jidDecode(undefined) dentro do Baileys.
Três consequências, em ordem de gravidade:
- A exceção aborta o restante do lote de eventos. O
tryque envolve esse trecho cobre tambémconnection.update,messages.upsert,creds.updatee os demais handlers do mesmo lote doev.process. Uma chamada perdida pode, portanto, descartar eventos que nada têm a ver com chamada. - O webhook
CALLdooffernunca é entregue, porquesendDataWebhook()vem depois do envio. Confirmado aqui comparando duas instâncias com a mesma configuração: na que o envio funcionou, o webhook recebeustatus: "offer"e depois osringing; na que estourou, só chegaram osringing— oofferdesapareceu. Quem integra perde justamente o evento que indica a chamada entrando. call.fromé modificado antes do webhook. Quando o mapeamento funciona, o payload doCALLsai com o telefone no lugar do@lidoriginal, ou seja, o mesmo campo tem significado diferente dependendo de o mapeamento existir ou não.
Como reproduzir
- Instância Baileys com
rejectCall: trueemsgCallpreenchido. - Ligar para o número a partir de uma conta que nunca trocou mensagem com ele (para não haver mapeamento LID→telefone).
- A chamada é cortada, a mensagem não chega e o log mostra o TypeError acima. O webhook não recebe o evento com
status: "offer".
Capturas de Tela/Vídeos
Sem resposta
Qual versão da API você está usando?
v2.3.7 (evoapicloud/evolution-api:latest, baileys 7.0.0-rc.9)
Qual é o seu ambiente?
Docker
Outras especificações do ambiente
Docker Swarm, Postgres 14, Redis, instâncias Baileys atrás de proxy HTTP.
- Dominant language
- TypeScript
- Stars
- 10.2k
- Forks
- 7.5k
- Avg merge
- 6d 19h
- Merged PRs (30d)
- 4
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from evolution-foundation/evolution-api
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
evolution-foundation/evolution-api#2796 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
evolution-foundation/evolution-api#2795 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
evolution-foundation/evolution-api#2782 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
evolution-foundation/evolution-api#2723 ·
Maintainers usually reply within 4 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
evolution-foundation/evolution-api#2704 ·
Maintainers usually reply within 4 days
All issues in evolution-foundation/evolution-api
Similar issues
-
review: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
1lck/Lithe-IDEA#2432 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
openpickleball/frontend#222 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
abhigyanpatwari/GitNexus#4124 ·
Maintainers usually reply within 1 day
-
area:web enhancement P2
Difficulty 1/5 Under an hour Newbie friendliness 88/100
agent-of-empires/agent-of-empires#6076 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
laaielichter/Godotwright#250 ·
Maintainers usually reply within 1 day