fix: canonicalize JIDs in GetAvatar, DeleteMessageEveryone and EditMessage - #130
Open
FlavioPulli wants to merge 1 commit into
Open
Conversation
…ssage
CreateJID intentionally prefixes phone numbers with "+"
(+55...@s.whatsapp.net). Message sending tolerates it because whatsmeow
normalizes the JID during usync/device resolution, and the raw-node
paths (typing, receipts, reactions) already strip it via
utils.CanonicalJID — but three paths still use the prefixed JID as-is:
- GetAvatar: GetProfilePictureInfo runs a usync IQ against the JID,
querying a nonexistent "+..." user and timing out after ~75s
("info query timed out") instead of returning the picture.
- DeleteMessageEveryone / EditMessage: the JID lands inside the
protocolMessage Key of the revoke/edit, so receiving devices look up
a chat named "+..." that doesn't exist and silently ignore the
operation.
Apply utils.CanonicalJID right after ParseJID in all three, matching
what the send/receipt paths already do. No-op for group and @lid JIDs
(their CreateJID paths never add the prefix).
Reviewer's guide (collapsed on small PRs)Reviewer's GuideCanonicalize user chat JIDs using utils.CanonicalJID in DeleteMessageEveryone, EditMessage, and GetAvatar so that downstream WhatsApp operations address valid, normalized users instead of Sequence diagram for canonicalizing JIDs in DeleteMessageEveryone/EditMessage/GetAvatarsequenceDiagram
participant messageService
participant userService
participant utils
participant client
participant whatsappServer
rect rgb(230,230,250)
messageService->>utils: CanonicalJID(recipient)
utils-->>messageService: recipient
messageService->>client: SendMessage(DeleteMessageEveryone with protocolMessage Key recipient)
client->>whatsappServer: Send revoke message
whatsappServer-->>client: Ack revoke
end
rect rgb(230,250,230)
messageService->>utils: CanonicalJID(recipient)
utils-->>messageService: recipient
messageService->>client: SendMessage(EditMessage with protocolMessage Key recipient)
client->>whatsappServer: Send edit message
whatsappServer-->>client: Ack edit
end
rect rgb(250,230,230)
userService->>utils: CanonicalJID(jid)
utils-->>userService: jid
userService->>client: GetProfilePictureInfo(jid, preview)
client->>whatsappServer: usync IQ for avatar
whatsappServer-->>client: Avatar info
client-->>userService: Avatar info
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since
ParseJIDis now immediately followed byutils.CanonicalJIDin multiple places, consider extracting a small helper (e.g.,ParseCanonicalJID) to centralize this pattern and reduce duplication in the services.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `ParseJID` is now immediately followed by `utils.CanonicalJID` in multiple places, consider extracting a small helper (e.g., `ParseCanonicalJID`) to centralize this pattern and reduce duplication in the services.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Author
|
Superseded by #163, which targets Editing the base branch of this PR was not possible: Leaving this one open — closing it is your call. |
ecosb2b
pushed a commit
to ecosb2b/evo-go-v2
that referenced
this pull request
Aug 5, 2026
Merges the Athene fork, which sits 11 commits ahead of the same upstream base and had already solved — in production — the three problems this fork was working through, plus a batch of upstream PRs we had not picked up. Only pkg/whatsmeow/service/whatsmeow.go conflicted (6 hunks); the other 63 files merged cleanly. Every conflict was resolved in favour of the incoming version, because each one was a place where both forks fixed the same bug and theirs is the one we chose to keep: - Connection leak: their getAuthContainer/sharedAuthContainer replaces our storeContainer/storeContainerHolder. Same fix, but theirs is a backport of upstream PR evolution-foundation#117, so it will converge with upstream instead of conflicting when that PR merges. It also caps SQLite at MaxOpenConns(1), which ours did not. - Reconnection: their runtime supervisor replaces our EnableAutoReconnect=true. Ours stopped the automatic disconnect loop but left ReconnectClient reachable from the API endpoint and the send retry, so those paths could still spawn a second client. Their runtime token refuses to start a second runtime for an instance from any path, waits for the previous goroutine to exit, deduplicates concurrent reconnects, backs off exponentially with jitter, and probes to confirm the reconnect actually connected. - Shared maps: ClientMapsMu closes the "fatal error: concurrent map writes" hole, which was still open on our side and kills the whole process rather than panicking a single request. Also arriving with the merge: upstream PRs evolution-foundation#149, evolution-foundation#135, evolution-foundation#34, evolution-foundation#100, evolution-foundation#143, evolution-foundation#137, evolution-foundation#120, evolution-foundation#130, evolution-foundation#151 and evolution-foundation#122; multi-webhook fan-out; POST /send/product; POST /user/savecontact; GET /server/stats and the dashboard; the whatsmeow update to 20260721; and removal of the 61 MB compiled binary that was tracked in git. Our GHCR workflow did not conflict and is preserved. store_container_test.go was adapted to the incoming implementation: it now exercises getAuthContainer, asserts against their MaxOpenConns of 20, and resets sharedAuthContainer between tests, since that container is a package-level global and would otherwise carry between tests and invalidate the pg_stat_activity measurements. It is kept alongside their auth_container_retry_test.go because it measures something theirs does not: the connection count the server actually sees. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
CreateJIDintentionally prefixes phone numbers with+(+55...@s.whatsapp.net). Message sending tolerates it because whatsmeow normalizes the JID during usync/device resolution, and the raw-node paths (typing, receipts, reactions) already strip it viautils.CanonicalJID— but three paths still use the prefixed JID as-is:GetProfilePictureInforuns a usync IQ against the JID, querying a nonexistent+...user and timing out after ~75s (info query timed out) instead of returning the picture.protocolMessageKey of the revoke/edit, so receiving devices look up a chat named+...that doesn't exist and silently ignore the operation.Apply
utils.CanonicalJIDright afterParseJIDin all three, matching what the send/receipt paths already do. No-op for group and@lidJIDs (theirCreateJIDpaths never add the prefix).Summary by Sourcery
Canonicalize user JIDs before invoking avatar retrieval and message revoke/edit operations to ensure they target the correct chat and user.
Bug Fixes: