{{ message }}
Repository navigation
fix(WhatsApp): resolve LID jids through jid_map for 1:1 and group messages - #1453
Merged
abrignoni merged 1 commit intoSep 28, 2026
Merged
Conversation
…sages Newer msgstore.db files key 1:1 chats and group senders by a LID jid (...@lid), while wa.db's wa_contacts.jid holds the ...@s.whatsapp.net form. The 1:1 artifact inner-joined wa_contacts on the chat's own jid, so every message in a LID-keyed chat, and in any chat without a contact row, was dropped. The group artifact kept its rows but left Sending Party empty for LID senders. Match wa_contacts through msgstore.db jid_map (lid_row_id -> jid_row_id) when that table exists, make the 1:1 contact join a LEFT JOIN, and fall back to the jid when no contact or WhatsApp name is found. On one Pixel 10 / Android 17 / WhatsApp 2.26.36.74 extraction: 1:1 rows 0 -> 29 (29 in msgstore.db), group rows with an empty sender 7 -> 0. Synthetic-database tests added; they fail on the previous code. Co-Authored-By: Claude Opus 5.5 <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.

Problem
Newer WhatsApp
msgstore.dbfiles key 1:1 chats, and the sender of group messages, by a LID jid (…@lid).wa.db'swa_contacts.jidholds the…@s.whatsapp.netform.wa_contactson the chat's ownjid.raw_stringwith an innerJOIN. Every message in a LID-keyed chat was dropped, and so was every message in a chat with nowa_contactsrow. On the device below the artifact produced no output at all althoughmsgstore.dbholds 29 1:1 messages.LEFT JOIN), butSending Partywas empty for every LID sender.Change
msgstore.dbhas ajid_maptable (lid_row_id INTEGER PRIMARY KEY, jid_row_id INTEGER, sort_id INTEGER) linking a LID jid row to a phone-number jid row. A new helper_contact_jid()addsLEFT JOIN jid_map/LEFT JOIN jid AS mapped_jidand matcheswa_contacts.jidagainstCOALESCE(mapped_jid.raw_string, jid.raw_string). Whenjid_mapdoes not exist (older databases) the query is the same as before apart from the points below.wa_contactsjoin is now aLEFT JOIN, so messages whose chat matches no contact are reported instead of dropped.Other Participant WA User Nameand groupSending Party: when no contact matches, orwa_nameis NULL/empty, the value falls back to the jid (mapped phone-number jid if there is one, otherwise the chat's/sender's own jid). This follows the jid fallbackget_whatsapp_contactsalready uses forName, and keeps distinct chats distinct in the conversation view instead of merging every nameless chat under an empty discriminator.Sending Party JIDfalls back the same way when no contact matches.notesandlast_update_dateupdated for both artifacts. Headers and column order are unchanged.Evidence
Data-proven on one device: Pixel 10, Android 17, com.whatsapp versionName 2.26.36.74 (vc 263607422), full-file-system extraction. Counts measured with direct SQL on
msgstore.db/wa.dband compared against ALEAPP output before and after:recipient_count=0@lidjid_maprow whose mapped jid is inwa_contacts@s.whatsapp.netwithout contactSending Party@lid, all resolved throughjid_mapOn this device 18 of the 29 1:1 rows show a jid as participant name (the 3 contactless rows plus rows whose contact has no
wa_name).What
jid_mapmeans is inferred from its column names, itsjid_bd_for_jid_map_trigger(DELETE FROM jid_map WHERE jid_row_id=old._id OR lid_row_id=old._id) and the result above; no WhatsApp source documents it. The mapping is evidenced on this one device only.Tests
admin/test/scripts/test_whatsapp_lid_contacts.pybuilds syntheticmsgstore.db/wa.dbfiles (no real evidence bytes): a LID-keyed chat with ajid_maprow, a phone-keyed chat, a contactless chat and a group with a LID sender, plus a variant withoutjid_map. All three tests fail onmainand pass with this change.unittest discover -s admin/test/scripts(rebased on fb0518e): 547 tests, the only failures are 5 intest_dependency_compatibility/test_sourcepath_helper, which fail identically on unmodifiedmainon this Windows machine (WinError 32file lock in temp cleanup).pylint --disable=C,Ron both files: 10.00/10;lint_changed.py --base-ref origin/main: no new warnings.check_claim_language,check_conversation_column_order,check_artifact_paths,check_implicit_concat,check_artifact_descriptions,check_artifact_returns,check_source_path,check_html_safety: pass.check_source_file_columnreportsdata_headers is not literalfor the two message artifacts, same as onmain.Not covered
sample_datarow counts were not re-measured; images whose chats are LID-keyed will report more 1:1 rows.get_whatsapp_call_logsstill uses an innerJOIN wa_contacts ON wa_contacts.jid=jid.raw_string, so LID-keyed calls would be dropped the same way. Not changed here: the test device has no call log rows, so the fix would be unexercised.whatsAppExtended.pyalready usesLEFT JOINs, so no rows are lost there, but its contact names are not resolved for LID jids.recipient_countNULL on this device is excluded by both queries, as before.ChatStorage.sqlite, a different schema; not checked for an equivalent issue.🤖 Generated with Claude Code