PICTURE / USER_ABOUT / BUTTON_CLICK are accepted in NATS_GLOBAL_EVENTS but never published: missing cases in the NATS switch of SendToGlobalQueues

Open Beginner friendly
#193 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
backend

Research direction

Start in pkg/whatsmeow/service/whatsmeow.go at SendToGlobalQueues and compare the AMQP mapping with the NATS switch. Check the declarations in pkg/internal/event_types/event_types.go, then ensure Picture, UserAbout, and ButtonClick are mapped for configured NATS events and are published rather than dropped; consider the issue's requested guardrail for unmapped events.

Written by the indexing model from the issue text.

Description

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

Related but distinct: #105 reports the same class of bug (an event type that is
accepted by configuration but has no case in a dispatch switch), for Passkey*
events on the webhook path. This one is about PICTURE / USER_ABOUT /
BUTTON_CLICK on the NATS path.

What did you do?

Ran 0.7.2 with NATS global events enabled and a subscription list that includes
PICTURE and USER_ABOUT:

NATS_GLOBAL_ENABLED=true
NATS_GLOBAL_EVENTS=MESSAGE,SEND_MESSAGE,READ_RECEIPT,PRESENCE,CHAT_PRESENCE,CALL,CONNECTION,QRCODE,GROUP,CONTACT,LABEL,PICTURE,USER_ABOUT,NEWSLETTER,HISTORY_SYNC

All three values are declared valid in pkg/internal/event_types/event_types.go
(lines 18-20, 37-39, 57-58), so the configuration is accepted without warning.

What did you expect?

Picture and UserAbout events to be published to NATS, since they are in the
subscription list and the gateway does receive them from whatsmeow.

What did you observe instead of what you expected?

They are silently dropped. Over 4 days of a single instance:

event received by gateway published to NATS
Picture 9 0
UserAbout 3 0

(Event received of type Picture appears in the logs; nothing ever lands in the
consumer.)

Cause

SendToGlobalQueues in pkg/whatsmeow/service/whatsmeow.go has two independent
switch eventType blocks that map whatsmeow event names to global event types.

The AMQP branch maps them (lines 2519-2522):

case "Picture":
    globalEventType = "PICTURE"
case "UserAbout":
    globalEventType = "USER_ABOUT"

The NATS branch (switch at line 2560) has no such cases, so both fall through
to the default at line 2587:

default:
    globalEventType = ""
}

// Verifica se o evento está na lista de eventos globais NATS
if globalEventType != "" && utils.Find(w.config.NatsGlobalEvents, globalEventType) {

globalEventType == "" fails the guard and the event is dropped with no log line.
The result is a dead subscription: configured, accepted, and impossible to
satisfy. BUTTON_CLICK has the same shape — declared in event_types.go and
emitted as a separate ButtonClick event, but absent from the NATS switch.

Suggested fix

Adding the missing cases to the NATS switch would resolve it:

case "Picture":
    globalEventType = "PICTURE"
case "UserAbout":
    globalEventType = "USER_ABOUT"
case "ButtonClick":
    globalEventType = "BUTTON_CLICK"

More robustly, the two switches are the same mapping duplicated and have already
drifted apart — extracting one shared mapEventToGlobalType(eventType) string
used by both branches would prevent the next divergence. I have not sent a PR for
this because the right shape depends on how you would rather handle the
duplication; happy to do it either way if you have a preference.

A cheap guardrail regardless: log at default: in the NATS branch, the way the
AMQP branch already does (Event %s not mapped to global event type). The silent
drop is what makes this hard to notice — the configuration looks correct and
nothing complains.

Version

0.7.2

Dominant language
Go
Stars
878
Forks
461
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from evolution-foundation/evolution-go

All issues in evolution-foundation/evolution-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.