Skip to content

fix(whatsapp): resolve LID aliases on modern platforms/ session layout (#36664) - #54083

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-6917296d
Jun 28, 2026
Merged

fix(whatsapp): resolve LID aliases on modern platforms/ session layout (#36664)#54083
teknium1 merged 3 commits into
mainfrom
hermes/hermes-6917296d

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

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 legacy get_hermes_home()/"whatsapp"/"session", while the adapter launches the bridge against get_hermes_dir("platforms/whatsapp/session", "whatsapp/session"). On any install without a legacy dir, the bridge writes lid-mapping-*.json under platforms/whatsapp/session but the resolver looked in an empty whatsapp/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: resolve session_dir via get_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_authorized E2E for the modern layout — guards the actual silently-dropped-sender path end-to-end.

Validation

Before After
Modern layout expand_whatsapp_aliases("<lid>@lid") {"<lid>"} (drop) {"<lid>", "<phone>"}
Legacy layout works works
LID sender vs phone allowlist (modern) rejected (dropped) authorized
Targeted tests 39/39 pass

Verified E2E with real imports against temp HERMES_HOME on 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

WhatsApp LID session-path fix

fesalfayed and others added 3 commits June 28, 2026 01:30
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.
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (#36665) — guards the actual
silently-dropped-LID-sender path from #36664.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-6917296d vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11617 on HEAD, 11617 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 6098 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/whatsapp WhatsApp Business adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P1 High — major feature broken, no workaround labels Jun 28, 2026
@teknium1
teknium1 merged commit 9f7d520 into main Jun 28, 2026
30 checks passed
@teknium1
teknium1 deleted the hermes/hermes-6917296d branch June 28, 2026 09:05

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: Uses get_hermes_dir() with fallback paths for both layouts
  • tests/gateway/test_unauthorized_dm_behavior.py: 1 test for modern layout
  • tests/gateway/test_whatsapp_identity.py: 2 tests — modern + legacy layout
  • infographic/: 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround platform/whatsapp WhatsApp Business adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants