fix(whatsapp): resolve LID aliases on modern platforms/ session layout (#36664) - #54083
Merged
Conversation
expand_whatsapp_aliases hardcoded get_hermes_home()/whatsapp/session, but
the adapter writes lid-mapping files via get_hermes_dir("platforms/whatsapp/
session", "whatsapp/session"). On installs without the legacy directory the
two paths diverge, so the resolver finds no mappings and returns the bare LID,
which misses the allowlist and silently drops the message. Resolve through the
same helper so both sides stay in lockstep on new and legacy layouts.
Contributor
🔎 Lint report:
|
This was referenced Jun 28, 2026
tonydwb
reviewed
Jun 28, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: LGTM
Resolves WhatsApp LID aliases on modern platforms/whatsapp/session layout in addition to legacy whatsapp/session. Fixes #36664 where LID senders were silently dropped on modern installs.
Changes
gateway/whatsapp_identity.py: Usesget_hermes_dir()with fallback paths for both layoutstests/gateway/test_unauthorized_dm_behavior.py: 1 test for modern layouttests/gateway/test_whatsapp_identity.py: 2 tests — modern + legacy layoutinfographic/: Diagram
Looks Good
get_hermes_dir("platforms/whatsapp/session", "whatsapp/session")correctly handles both layouts- Tests cover both modern and legacy session directory structures
- Clean one-line fix with clear regression test
Reviewed by Hermes Agent
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.
Summary
WhatsApp LID senders are no longer silently dropped on modern
platforms/installs — the alias resolver now reads the same session directory the adapter writes to.Root cause:
expand_whatsapp_aliases()hardcoded the legacyget_hermes_home()/"whatsapp"/"session", while the adapter launches the bridge againstget_hermes_dir("platforms/whatsapp/session", "whatsapp/session"). On any install without a legacy dir, the bridge writeslid-mapping-*.jsonunderplatforms/whatsapp/sessionbut the resolver looked in an emptywhatsapp/session— so a LID sender never resolved to their phone, failed the allowlist, and the message was dropped with nothing surfaced to the user. The module docstring claimed to be the single source of truth "so the two paths can never drift apart"; they had drifted.Changes
gateway/whatsapp_identity.py: resolvesession_dirviaget_hermes_dir("platforms/whatsapp/session", "whatsapp/session")(same call the adapter uses) — works on both modern and legacy layouts.tests/gateway/test_whatsapp_identity.py: new unit tests covering modern + legacy layout resolution (fesalfayed).tests/gateway/test_unauthorized_dm_behavior.py: added_is_user_authorizedE2E for the modern layout — guards the actual silently-dropped-sender path end-to-end.Validation
expand_whatsapp_aliases("<lid>@lid"){"<lid>"}(drop){"<lid>", "<phone>"}Verified E2E with real imports against temp
HERMES_HOMEon both layouts.Credit: salvages @fesalfayed's fix from #36665 (issue author, earliest of the cluster). Duplicate PRs #38712 (@ashishpatel26) and #39823 (@yinkev) submitted the same one-line fix and are credited on close.
Infographic