Fix outdated client, media download 403, and LID contact lookup - #307
Open
lumnia-dev-ia wants to merge 1 commit into
Open
Fix outdated client, media download 403, and LID contact lookup#307lumnia-dev-ia wants to merge 1 commit into
lumnia-dev-ia wants to merge 1 commit into
Conversation
- bump whatsmeow (fresh clones currently fail to pair: WhatsApp rejects the pinned version with Client outdated 405, seen as websocket close 1006) and update the five call sites that now take a context.Context - keep the query string in extractDirectPathFromURL: whatsmeow appends its own parameters with '&', assuming the signed query is already present, so stripping it produced a malformed URL and every media download returned 403 - resolve LID JIDs to phone JIDs via Store.GetAltJID before the contact lookup, so chats identified by @lid get real contact names instead of a raw 15-digit identifier; fallback chain extended to full name, business name, push name, then phone number
This was referenced Aug 11, 2026
1 task
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.
Three bug fixes plus the dependency bump they depend on. No new features — I kept
this deliberately narrow so it's easy to review.
Context: I've been running this project daily and hit each of these in turn. The
first one currently stops a fresh clone from working at all.
1. Outdated
whatsmeow— the QR code never appearsSymptom. On a fresh clone,
go run main.goconnects and immediately drops:No QR code, no way to pair. The underlying cause is WhatsApp rejecting the
pinned client version with
Client outdated (405), which surfaces only as the1006 close.
Fix. Bump
whatsmeowto latest. That bump changes five signatures to take acontext.Context, so those call sites are updated too:client.Downloadsqlstore.Newcontainer.GetFirstDeviceclient.GetGroupInfoclient.Store.Contacts.GetContactThis matches what several people worked out independently in #94, #136 and #153.
2. Media downloads always fail with HTTP 403
Symptom.
download_mediareturnsFailed to download mediafor everyattachment, even when the message row has complete media metadata (url,
mediaKey, sha256, length). The Python side swallows the detail; adding a log
line to the Go handler reveals
download failed with status code 403.Root cause.
extractDirectPathFromURLstrips the query string:But
whatsmeowbuilds the final URL by concatenating its own parameters with&(download.go,DownloadMediaWithPath):It uses
&because it assumesdirectPathalready carries the WhatsApp-signedquery (
?ccb=…&oh=…&oe=…) — which is exactly what the protobufDirectPathcontains. Stripping it produces a URL with no
?at all, so everything afterthe path becomes part of the path, and the media host rejects it.
Fix. Preserve the query string.
3. Contact search misses LID-identified chats
Symptom.
search_contactsreturns nothing for people who are clearly in theaddress book, and those chats show a bare 15-digit number as their name. On my
install this affected 304 of 307 one-to-one chats stored with an
@lidJID.Root cause. WhatsApp increasingly identifies chats by an opaque LID
(
123456789012345@lid) rather than a phone JID.GetChatNamepasses that JIDstraight to
client.Store.Contacts.GetContact, but the contact store is keyedby phone JID — so the lookup always misses and the code falls back to
jid.User, i.e. the raw LID.whatsmeowalready maintains the mapping (whatsmeow_lid_map; 5,439 rows on myinstall) and exposes
Store.GetAltJIDfor exactly this.Fix. Resolve LID → phone JID before the contact lookup, and extend the
fallback chain to
FullName → BusinessName → PushName → phone number. Fallingback to the phone number is still far more useful than an opaque LID.
Not included, but worth flagging
main()blocks on the QR channel andreturns after a 3-minute timeout. That'sfine interactively, but under a service manager (launchd/systemd) it means the
process exits and gets restarted forever, with no way to see a QR code. Making
the connect path non-blocking fixes it, but it's a behavioural change rather
than a bug fix, so I left it out of this PR. Happy to open a separate one if
you're interested.
Testing
Applied to a clean clone of
main: builds withgo build, cleango vetandgofmt. Verified against a live account — pairing works, media downloadssucceed (confirmed by opening a received PDF), and contact search returns the
right names for LID chats.