Conversation
The Archive case asserts postMap["data"] to map[string]interface{}, but at that
point it still holds the raw *events.Archive. The assertion panics on every
archive event:
Event handler panicked while handling a *events.Archive:
interface conversion: interface {} is *events.Archive,
not map[string]interface {}
whatsmeow recovers the panic and logs it, so nothing crashes — the event simply
never reaches the webhook, silently.
Every other case in this switch marshals and unmarshals postMap["data"] into a
map before asserting. Archive was the only one missing that step. Six call sites
do the assertion; the other five are already guarded.
Reviewer's GuideThe Archive event handler now applies the same JSON normalization used by other event cases before asserting webhook data as a map, eliminating the panic that previously prevented Archive events from reaching the webhook while preserving existing error handling and payload enrichment. Sequence diagram for normalized Archive webhook deliverysequenceDiagram
participant Whatsmeow as Whatsmeow event dispatcher
participant Handler as myEventHandler
participant Webhook as Webhook
Whatsmeow->>Handler: myEventHandler(rawEvt)
Handler->>Handler: json.Marshal(postMap["data"])
Handler->>Handler: json.Unmarshal(jsonBytes, &parsed)
Handler->>Handler: dataMap["JID"] = evt.JID
Handler->>Handler: dataMap["Timestamp"] = evt.Timestamp
Handler->>Webhook: Deliver Archive payload
Webhook-->>Whatsmeow: Archive event received
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Sourcery assessment
Needs a human reviewer. This makes Archive events reach the webhook instead of panicking, so an incorrect payload could trigger an external notification or downstream webhook action that cannot be undone by reverting the change. The resulting event is bounded and the implementation can be corrected normally, but already-delivered webhook calls outlive the revert.
The problem
The
*events.Archivecase assertspostMap["data"]tomap[string]interface{}, but at that point it still holds the raw event. The assertion panics every time a chat is archived:postMap["data"]is set torawEvtbefore the switch, so this is not a race or an edge case — it fails on every Archive event, in every deployment.Why nobody noticed
whatsmeow recovers the panic in its event dispatcher and logs it at ERROR level. Nothing crashes, no instance drops. The Archive event simply never reaches the webhook, and the only trace is one line in the log.
We hit it 4 times in 24 hours on a small deployment while investigating something unrelated.
The fix
Every other case in this switch marshals
postMap["data"]to JSON and unmarshals it back into a map before asserting.Archivewas the only one missing that step.Six call sites perform this assertion. Five are already guarded (
Connected,PairSuccess,TemporaryBan,LoggedOut, andMessage, which uses the comma-ok form). This makesArchivethe sixth.A note for reviewers
The marshal/unmarshal block is now repeated five times in this file, and it would read better as a small helper — something like
dataMapFrom(postMap). I kept the change minimal and matched the surrounding style instead, since extracting it would touch cases that currently work. Happy to send that as a follow-up if you'd prefer it.Testing
go build ./...againstmain, clean.Summary by Sourcery
Bug Fixes: