Skip to content

fix(whatsapp): thread authDir through command authorization and owner bypass for LID JID resolution - #93379

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
xialonglee:fix/issue-77755-whatsapp-lid-authdir
Jul 1, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
xialonglee:fix/issue-77755-whatsapp-lid-authdir

Conversation

@xialonglee

@xialonglee xialonglee commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

WhatsApp group commands (/new, /stop, /status) are silently ignored when Baileys reports the sender as a LID JID (@lid) instead of a phone JID (@s.whatsapp.net), even when the sender is the configured owner.

Root cause: resolveWhatsAppCommandAuthorized() and isOwnerSender() called getSelfIdentity()/getSenderIdentity() without passing authDir, so the LID-to-phone reverse mapping files (lid-mapping-<lid>_reverse.json) in the auth directory could not be found. The sender fell through to unauthorized, and the command was dropped.

Fixes #77755

Why This Change Was Made

Thread account.authDir through both command authorization (resolveWhatsAppCommandAuthorized) and group owner-bypass identity resolution (isOwnerSender), enabling proper LID JID → phone E.164 resolution before owner/allowlist checks.

This is the narrowest fix: the existing resolveComparableIdentity() helper already accepts authDir and passes it to jidToE164() for LID identity resolution. The only gap was the two call sites that weren't forwarding the parameter.

User Impact

  • Before: WhatsApp group owner commands silently ignored when Baileys uses LID JID sender format (intermittent, depends on Baileys internal state)
  • After: Owner commands in WhatsApp groups always authorized, regardless of whether Baileys reports the sender as phone JID or LID JID
  • Affected users: WhatsApp channel users whose Baileys session uses LID-based sender identities for group messages

Evidence

  • pnpm test extensions/whatsapp/src/inbound/access-control.test.ts — 16/16 passed (including new LID regression test)
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json — clean
  • CI: all checks passing (build, lint, test-types, contracts, boundaries, etc.)
  • Autoreview: ClawSweeper reviewed, patch quality 🦞 diamond lobster

Real behavior proof

Behavior addressed: WhatsApp group commands (e.g. /status) from the configured owner are properly authorized when Baileys reports the sender as a LID JID (<LID>@lid) instead of a phone JID, via the reverse LID mapping file in the auth directory.

Real environment tested: Linux x86_64, Node 24.13.1, branch fix/issue-77755-whatsapp-lid-authdir at commit f74779fe9a, production WhatsApp config with real Baileys auth directory containing LID reverse mappings.

Exact steps after this patch:

# 1. Build and start gateway with PR branch
pnpm build
OPENCLAW_HOME=$HOME OPENCLAW_ALLOW_OLDER_BINARY_DESTRUCTIVE_ACTIONS=1 pnpm openclaw gateway

# 2. Send /status from owner's phone in a WhatsApp group
# 3. Observe gateway logs

Gateway log evidence — WhatsApp connected and listening:

[whatsapp] Listening for WhatsApp inbound messages (DM + all groups; sender allowlist configured).

Sending /status from owner's phone in WhatsApp group. Gateway received and authorized the command:

inbound message
Inbound message <GROUP_JID>@g.us -> REDACTED (group, 101 chars)
Sending message -> sha256:e4c4dd672a3d
Sent message 3EB048CA4F762AB9930161 (875ms)

Temporary diagnostic probe confirming LID JID → E.164 resolution path with authDir:

[PROOF] isOwnerSender authDir=~/.openclaw/credentials/whatsapp/default
        sender.jid=(none) sender.lid=<LID>@lid sender.e164=REDACTED
[PROOF] isOwnerSender => true (owners=["REDACTED"] sender=REDACTED)

[PROOF] resolveWhatsAppCommandAuthorized authDir=~/.openclaw/credentials/whatsapp/default
        sender.jid=(none) sender.lid=<LID>@lid sender.e164=REDACTED isGroup=true
[PROOF] resolveWhatsAppCommandAuthorized => true (senderId=REDACTED)

Key facts confirmed by live probe:

  • Baileys reported the sender as LID JID <LID>@lid — no phone JID present
  • authDir was correctly threaded to getSenderIdentity()/getSelfIdentity()
  • LID → E.164 reverse mapping succeeded via lid-mapping-<LID>_reverse.json → owner phone
  • Owner authorization passed in both isOwnerSender and resolveWhatsAppCommandAuthorized paths
  • Bot replied successfully (875ms send latency)

Observed result after fix: The owner's /status command in a WhatsApp group, where Baileys reports the sender as <LID>@lid, is correctly resolved to the owner's phone number via the authDir reverse mapping, authorized as owner, and the bot responds normally.

What was not tested: The "before" (broken) behavior on main was not reverted and retested on this live setup, as doing so would disrupt the running gateway. The main-branch gap was confirmed by source inspection (see ClawSweeper review evidence: inbound-policy.ts:182 and group-gating.ts:81 on main call getSenderIdentity(msg) without authDir).

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: S proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 1, 2026, 9:25 AM ET / 13:25 UTC.

Summary
The PR threads WhatsApp account authDir into command authorization and group owner-bypass identity resolution and adds a LID reverse-mapping regression test.

PR surface: Source +6, Tests +51. Total +57 across 4 files.

Reproducibility: yes. Current main and v2026.6.11 call getSelfIdentity/getSenderIdentity without authDir at the command authorization and owner-bypass sites, while the existing resolver can map LID JIDs through authDir reverse mapping files; the PR body now adds redacted live after-fix WhatsApp proof.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: extensions/whatsapp/src/inbound/access-control.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #77755
Summary: This PR is the open candidate fix for the canonical WhatsApp group command LID sender authorization issue; the wrong-recipient/session-state report remains only partially overlapping.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

Maintainer options:

  1. Decide the mitigation before merge
    Land this plugin-local authDir threading fix after ordinary maintainer review, while leaving broader WhatsApp LID delivery and session isolation work tracked separately.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed because the focused code patch and live proof are already present; the remaining action is normal maintainer merge review.

Security
Cleared: No concrete security or supply-chain concern was found; the diff is plugin-local authorization plumbing plus a temporary-file regression test with no new dependencies, workflows, package scripts, or secret handling.

Review details

Best possible solution:

Land this plugin-local authDir threading fix after ordinary maintainer review, while leaving broader WhatsApp LID delivery and session isolation work tracked separately.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main and v2026.6.11 call getSelfIdentity/getSenderIdentity without authDir at the command authorization and owner-bypass sites, while the existing resolver can map LID JIDs through authDir reverse mapping files; the PR body now adds redacted live after-fix WhatsApp proof.

Is this the best way to solve the issue?

Yes. Passing the existing account.authDir into the existing WhatsApp identity helpers is the narrowest maintainable fix, with no new resolver, config option, or parallel authorization path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against be2c4c65abd9.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted live WhatsApp/Baileys gateway and diagnostic logs showing the LID sender resolved through authDir, owner authorization passing, and the bot replying after the fix.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body includes redacted live WhatsApp/Baileys gateway and diagnostic logs showing the LID sender resolved through authDir, owner authorization passing, and the bot replying after the fix.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a normal-priority WhatsApp channel authorization bugfix with real group command impact but limited channel scope.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR body includes redacted live WhatsApp/Baileys gateway and diagnostic logs showing the LID sender resolved through authDir, owner authorization passing, and the bot replying after the fix.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted live WhatsApp/Baileys gateway and diagnostic logs showing the LID sender resolved through authDir, owner authorization passing, and the bot replying after the fix.
Evidence reviewed

PR surface:

Source +6, Tests +51. Total +57 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 12 6 +6
Tests 1 51 0 +51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 63 6 +57

What I checked:

Likely related people:

  • mcaxtr: Authored the multi-account inbound policy refactor that introduced the central inbound-policy path and touched group-gating/process-message around this authorization boundary. (role: recent WhatsApp inbound contributor and merger; confidence: high; commits: 458a52610a4d; files: extensions/whatsapp/src/inbound-policy.ts, extensions/whatsapp/src/auto-reply/monitor/group-gating.ts, extensions/whatsapp/src/auto-reply/monitor/process-message.ts)
  • steipete: Introduced the unified WhatsApp identity helper that already supports authDir-backed LID resolution and is reused by this PR. (role: identity helper contributor; confidence: medium; commits: 3b6d980c52c3; files: extensions/whatsapp/src/identity.ts)
  • edenfunf: Authored the merged WhatsApp authDir PN-to-LID mapping work in targets-runtime and send-api, which established nearby LID mapping behavior. (role: adjacent LID mapping contributor; confidence: medium; commits: fcdfa30703b8; files: extensions/whatsapp/src/targets-runtime.ts, extensions/whatsapp/src/inbound/send-api.ts, extensions/whatsapp/src/text-runtime.test.ts)
  • xialonglee: Beyond this PR, the same display identity appears on a merged WhatsApp Baileys retry/cache hooks change touching connection-controller and inbound monitor reliability paths. (role: recent adjacent WhatsApp reliability contributor; confidence: medium; commits: 84cf64770fc6; files: extensions/whatsapp/src/connection-controller.ts, extensions/whatsapp/src/inbound/monitor.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 15, 2026
… bypass for LID JID resolution

WhatsApp group commands (/new, /stop) can be ignored when Baileys reports the sender as a LID JID (@lid) instead of a phone JID (@s.whatsapp.net). The resolveWhatsAppCommandAuthorized() and isOwnerSender() functions called getSelfIdentity/getSenderIdentity without passing authDir, so the LID-to-phone reverse mapping could not happen.

Fix: thread account.authDir through both command authorization and group owner-bypass identity resolution paths so that LID JIDs are properly resolved to phone E.164 identities before owner/allowlist checks.
@xialonglee
xialonglee force-pushed the fix/issue-77755-whatsapp-lid-authdir branch from 0b37c7e to 845f4d7 Compare June 19, 2026 17:19
@xialonglee

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@xialonglee

xialonglee commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added live WhatsApp/Baileys behavior proof with redacted diagnostics:

  • Confirmed sender arrives as LID JID with no phone JID
  • Confirmed authDir threads correctly through resolveWhatsAppCommandAuthorized and isOwnerSender
  • Confirmed LID → E.164 reverse mapping resolves to owner phone
  • Confirmed owner authorization passes and bot replies successfully (875ms)
  • Gateway logs and probe output (redacted) included in PR body

@clawsweeper

clawsweeper Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 1, 2026
@vincentkoc
vincentkoc merged commit 85f7834 into openclaw:main Jul 1, 2026
203 of 211 checks passed
@xialonglee
xialonglee deleted the fix/issue-77755-whatsapp-lid-authdir branch July 1, 2026 16:26
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 2, 2026
… bypass for LID JID resolution (openclaw#93379)

* fix(whatsapp): thread authDir through command authorization and owner bypass for LID JID resolution

WhatsApp group commands (/new, /stop) can be ignored when Baileys reports the sender as a LID JID (@lid) instead of a phone JID (@s.whatsapp.net). The resolveWhatsAppCommandAuthorized() and isOwnerSender() functions called getSelfIdentity/getSenderIdentity without passing authDir, so the LID-to-phone reverse mapping could not happen.

Fix: thread account.authDir through both command authorization and group owner-bypass identity resolution paths so that LID JIDs are properly resolved to phone E.164 identities before owner/allowlist checks.

* fix(whatsapp): replace deprecated top-level fields with admission overrides in LID JID test
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
… bypass for LID JID resolution (openclaw#93379)

* fix(whatsapp): thread authDir through command authorization and owner bypass for LID JID resolution

WhatsApp group commands (/new, /stop) can be ignored when Baileys reports the sender as a LID JID (@lid) instead of a phone JID (@s.whatsapp.net). The resolveWhatsAppCommandAuthorized() and isOwnerSender() functions called getSelfIdentity/getSenderIdentity without passing authDir, so the LID-to-phone reverse mapping could not happen.

Fix: thread account.authDir through both command authorization and group owner-bypass identity resolution paths so that LID JIDs are properly resolved to phone E.164 identities before owner/allowlist checks.

* fix(whatsapp): replace deprecated top-level fields with admission overrides in LID JID test

(cherry picked from commit 85f7834)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WhatsApp group commands ignored when owner sender is reported as LID JID

2 participants