fix: panic on Archive event due to unchecked type assertion - #125
Open
FlavioPulli wants to merge 1 commit into
Open
fix: panic on Archive event due to unchecked type assertion#125FlavioPulli wants to merge 1 commit into
FlavioPulli wants to merge 1 commit into
Conversation
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.
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes a panic in Archive event handling by removing an unsafe type assertion on postMap["data"] and building the archive payload map directly, consistent with other event handlers. Flow diagram for Archive event handling in myEventHandlerflowchart TD
A[myEventHandler rawEvt] --> B[assert evt as *events.Archive]
B --> C[set postMap event = Archive]
C --> D[build data map directly]
D -->|postMap data| E[send webhook payload]
E --> F[LogInfo Chat archived]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
myEventHandlerbuildspostMapwithout a"data"key, so the*events.Archivecase assertingpostMap["data"].(map[string]interface{})(pkg/whatsmeow/service/whatsmeow.go:1820) 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 (Message, Receipt, etc.) — Archive was the only one missing the guard. This builds the data payload map directly, preserving the exact webhook shape.How to reproduce: pair an instance, archive any chat on the phone → the process dies with
panic: interface conversion: interface {} is nil, not map[string]interface {}.Summary by Sourcery
Bug Fixes: