Skip to content

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

Closed
fesalfayed wants to merge 1 commit into
NousResearch:mainfrom
fesalfayed:fix/whatsapp-identity-session-path
Closed

fix(whatsapp): resolve LID aliases on modern platforms/ session layout#36665
fesalfayed wants to merge 1 commit into
NousResearch:mainfrom
fesalfayed:fix/whatsapp-identity-session-path

Conversation

@fesalfayed

Copy link
Copy Markdown
Contributor

What does this PR do?

expand_whatsapp_aliases in gateway/whatsapp_identity.py reads the bridge's lid-mapping-*.json files to collapse a WhatsApp LID to its phone alias, but it hardcodes the session directory:

session_dir = get_hermes_home() / "whatsapp" / "session"

The WhatsApp adapter writes those files — and points the bridge at them via --session — through the consolidated-layout helper instead:

get_hermes_dir("platforms/whatsapp/session", "whatsapp/session")

get_hermes_dir(new, old) returns the legacy path only when it already exists on disk, otherwise the new platforms/... path. So on any install without a legacy whatsapp/session directory the bridge writes mappings to platforms/whatsapp/session while the resolver looks in whatsapp/session — empty/nonexistent. The resolver finds no mappings, returns the bare LID, the allowlist check misses, and the inbound message is silently dropped. The module docstring's "single source of truth … so the two paths can never drift apart" is contradicted by this line.

This routes the resolver through the same get_hermes_dir(...) call the adapter uses, so the read and write paths stay in lockstep on both the modern and legacy layouts and can't drift again.

Same root-cause-not-symptom approach as #35859 (merged): one minimal in-style change at the divergence point, no new bookkeeping, plus a regression test that fails on the old path and passes on the fixed one.

Related Issue

Fixes #36664

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/whatsapp_identity.pyexpand_whatsapp_aliases: resolve session_dir via get_hermes_dir("platforms/whatsapp/session", "whatsapp/session") (the adapter's helper) instead of the hardcoded get_hermes_home() / "whatsapp" / "session".
  • tests/gateway/test_whatsapp_identity.py — resolution test on both the modern platforms/whatsapp/session and legacy whatsapp/session layouts.

How to Test

pytest tests/gateway/test_whatsapp_identity.py -q

The modern-layout test fails on main (expand_whatsapp_aliases("<lid>@lid") returns {"<lid>"} only) and passes with this change (returns {"<lid>", "<phone>"}). Broader suite green:

pytest tests/gateway/test_whatsapp_identity.py tests/gateway/test_session.py \
  tests/gateway/test_unauthorized_dm_behavior.py tests/gateway/test_pairing.py -q
# 149 passed

Checklist

Code

  • My commit messages follow Conventional Commits
  • My PR contains only changes related to this fix
  • Tests pass
  • I've added tests for my changes
  • Tested on macOS 26.4, Python 3.11.15

Documentation & Housekeeping

  • N/A — behavior fix, no config/doc/schema changes.

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.
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround platform/whatsapp WhatsApp Business adapter comp/gateway Gateway runner, session dispatch, delivery labels Jun 1, 2026
@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jun 21, 2026
@fesalfayed

Copy link
Copy Markdown
Contributor Author

Validation refresh and duplicate-context note:

  • This PR keeps the resolver on the same get_hermes_dir("platforms/whatsapp/session", "whatsapp/session") path as the adapter.
  • Dedicated regressions cover both modern consolidated layout and legacy layout.
  • Local checks: ruff check . ✅, python scripts/check-windows-footguns.py --all ✅, python -m pytest tests/gateway/test_whatsapp_identity.py -q -o addopts=''2 passed, git diff --check ✅.

This is the same issue as #38712; happy for maintainers to take whichever branch they prefer, but this one includes both modern and legacy layout coverage.

teknium1 added a commit that referenced this pull request Jun 28, 2026
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.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #54083 — your fix was cherry-picked onto current main with your authorship preserved in git log (commit 263ffec). As the issue author you submitted this first; thanks for the clean fix and tests. We added one extra E2E test covering the allowlist-authorization path on top.

@teknium1 teknium1 closed this Jun 28, 2026
pai-scaffolde pushed a commit to pai-scaffolde/hermes-agent that referenced this pull request Jun 28, 2026
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (NousResearch#36665) — guards the actual
silently-dropped-LID-sender path from NousResearch#36664.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (NousResearch#36665) — guards the actual
silently-dropped-LID-sender path from NousResearch#36664.
Jasper6439 pushed a commit to Jasper6439/hermes-agent that referenced this pull request Jul 5, 2026
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (NousResearch#36665) — guards the actual
silently-dropped-LID-sender path from NousResearch#36664.
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (NousResearch#36665) — guards the actual
silently-dropped-LID-sender path from NousResearch#36664.
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (NousResearch#36665) — guards the actual
silently-dropped-LID-sender path from NousResearch#36664.
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (NousResearch#36665) — guards the actual
silently-dropped-LID-sender path from NousResearch#36664.
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
Add an _is_user_authorized E2E for the platforms/whatsapp/session layout
on top of fesalfayed's resolver fix (NousResearch#36665) — guards the actual
silently-dropped-LID-sender path from NousResearch#36664.
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:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades 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.

[Bug]: WhatsApp LID sender silently dropped — alias resolver reads wrong session dir on modern platforms/ layout

3 participants