Skip to content

fix(whatsapp): resolve LID↔phone aliases in allowlist matching#3830

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-deb3d2ef
Mar 30, 2026
Merged

fix(whatsapp): resolve LID↔phone aliases in allowlist matching#3830
teknium1 merged 1 commit intomainfrom
hermes/hermes-deb3d2ef

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Salvage of the LID mapping fix from PR #1863. The rest of that PR (unauthorized_dm_behavior, WHATSAPP_REPLY_PREFIX, config version bumps, planning doc) was either already on main or unrelated.

Problem

WhatsApp DMs can arrive with LID sender IDs (e.g. 900000000000001@lid) even when WHATSAPP_ALLOWED_USERS is configured with phone numbers (e.g. 15550000001). The existing allowlist check only stripped the @ suffix but didn't resolve the phone↔LID mapping, so valid users were denied.

Fix

Both the Python gateway and Node bridge now read the bridge session mapping files (lid-mapping-*.json) to resolve phone↔LID aliases:

  • gateway/run.py_normalize_whatsapp_identifier() strips JID/LID syntax, _expand_whatsapp_auth_aliases() walks mapping files to build a full alias set. _is_user_authorized() expands both the allowlist entries and the sender ID before matching.
  • scripts/whatsapp-bridge/allowlist.js — Extracted allowlist logic into a shared module with the same mapping-file resolution. bridge.js now uses matchesAllowedUser() instead of a simple array .includes().

Tests

  • 1 new Python test: LID sender matches phone allowlist via session mapping files
  • 3 Node tests: normalize, expand, matchesAllowedUser
  • 1641 gateway tests pass (7 pre-existing boot-md hook failures, unrelated)

Closes #1863
EOF; __hermes_rc=$?; printf 'HERMES_FENCE_a9f7b3'; exit $__hermes_rc

WhatsApp DMs can arrive with LID sender IDs even when
WHATSAPP_ALLOWED_USERS is configured with phone numbers. The allowlist
check now reads bridge session mapping files (lid-mapping-*.json) to
resolve phone↔LID aliases, matching users regardless of which
identifier format the message uses.

Both the Python gateway (_is_user_authorized) and the Node bridge
(allowlist.js) now share the same mapping-file-based resolution logic.

Co-authored-by: Frederico Ribeiro <fr@tecompanytea.com>
@teknium1 teknium1 merged commit 3e2c8c5 into main Mar 30, 2026
2 of 3 checks passed
itsXactlY pushed a commit to itsXactlY/hermes-agent that referenced this pull request Mar 30, 2026
…esearch#3830)

WhatsApp DMs can arrive with LID sender IDs even when
WHATSAPP_ALLOWED_USERS is configured with phone numbers. The allowlist
check now reads bridge session mapping files (lid-mapping-*.json) to
resolve phone↔LID aliases, matching users regardless of which
identifier format the message uses.

Both the Python gateway (_is_user_authorized) and the Node bridge
(allowlist.js) now share the same mapping-file-based resolution logic.

Co-authored-by: Frederico Ribeiro <fr@tecompanytea.com>
ozkikr added a commit to ozkikr/hermes-agent that referenced this pull request Apr 1, 2026
Local patch until upstream PR NousResearch#3830 lands.
Resolves LID format issues that caused message sender identification failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants