From b28cb5e26afd27730112408987e638eb14f974c5 Mon Sep 17 00:00:00 2001 From: Flavio Pulli Date: Fri, 24 Jul 2026 11:03:19 -0300 Subject: [PATCH] fix(whatsmeow): panic on Archive event due to unchecked type assertion myEventHandler builds postMap without a "data" key, so the Archive case asserting postMap["data"].(map[string]interface{}) panics the whole process whenever a chat is archived or unarchived on the paired phone. Every other case that reads postMap["data"] guards the key first (e.g. Message, Receipt); Archive was the only one missing it. Build the data payload map directly, preserving the exact webhook shape. --- pkg/whatsmeow/service/whatsmeow.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/whatsmeow/service/whatsmeow.go b/pkg/whatsmeow/service/whatsmeow.go index 366f0edb..d016db65 100644 --- a/pkg/whatsmeow/service/whatsmeow.go +++ b/pkg/whatsmeow/service/whatsmeow.go @@ -1817,12 +1817,15 @@ func (mycli *MyClient) myEventHandler(rawEvt interface{}) { doWebhook = true postMap["event"] = "Archive" - dataMap := postMap["data"].(map[string]interface{}) - dataMap["JID"] = evt.JID - dataMap["Timestamp"] = evt.Timestamp - dataMap["Action"] = evt.Action - dataMap["FromFullSync"] = evt.FromFullSync - postMap["data"] = dataMap + // postMap has no "data" key at this point, so asserting it as a map + // panics the whole process whenever a chat is (un)archived on the phone. + // Build the payload map directly instead. + postMap["data"] = map[string]interface{}{ + "JID": evt.JID, + "Timestamp": evt.Timestamp, + "Action": evt.Action, + "FromFullSync": evt.FromFullSync, + } mycli.loggerWrapper.GetLogger(mycli.userID).LogInfo("[%s] Chat archived", mycli.userID) case *events.HistorySync: