Skip to content

harden WhatsApp WebSocket URL override#97697

Merged
RomneyDa merged 1 commit into
mainfrom
codex/whatsapp-websocket-url-env
Jun 29, 2026
Merged

harden WhatsApp WebSocket URL override#97697
RomneyDa merged 1 commit into
mainfrom
codex/whatsapp-websocket-url-env

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

  • Rebased this PR onto main after feat(whatsapp): support Baileys WebSocket URL override #97155 merged the canonical WhatsApp Baileys waWebSocketUrl override.
  • Trimmed the diff so this PR now only adds validation for the trusted OPENCLAW_WHATSAPP_WEB_SOCKET_URL env fallback.
  • Rejects invalid env fallback values before Baileys socket creation while preserving explicit waWebSocketUrl call options over environment.

Verification

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-whatsapp.config.ts whatsapp/src/session.test.ts
  • pnpm exec oxfmt --check extensions/whatsapp/src/session.ts extensions/whatsapp/src/session.test.ts
  • pnpm install after one pnpm exec oxlint attempt hit dependency materialization ENOENT; install reported already up to date.
  • pnpm exec oxlint --deny-warnings --tsconfig config/tsconfig/oxlint.extensions.json extensions/whatsapp/src/session.ts extensions/whatsapp/src/session.test.ts
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main

@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web size: XS labels Jun 29, 2026
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label Jun 29, 2026
@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 1:47 PM ET / 17:47 UTC.

Summary
The PR validates OPENCLAW_WHATSAPP_WEB_SOCKET_URL as a ws:// or wss:// URL before passing the env fallback to Baileys, while keeping explicit waWebSocketUrl options higher priority.

PR surface: Source +15, Tests +19. Total +34 across 2 files.

Reproducibility: yes. from source inspection: current main passes the env fallback through as a raw string, while Baileys constructs a URL from waWebSocketUrl during socket creation. The PR adds a focused invalid-env regression test, though I did not run local tests in this read-only review.

Review metrics: 1 noteworthy metric.

  • Environment Validation Surface: 1 trusted env fallback tightened. The PR changes runtime behavior for OPENCLAW_WHATSAPP_WEB_SOCKET_URL, so maintainers should notice the fail-closed operator impact before merge.

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

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] The patch intentionally fail-closes invalid OPENCLAW_WHATSAPP_WEB_SOCKET_URL values; the env override has not shipped in the latest release, but maintainers should still own that operator-visible current-main behavior before merge.

Maintainer options:

  1. Accept The Fail-Closed Env Validation (recommended)
    Maintainers can merge this as the current-main upgrade path because the env override is unreleased and invalid non-WebSocket values should not reach Baileys.
  2. Pause For QA Stack Alignment
    Pause this follow-up if maintainers want the validation to land only after the broader QA Crabline consumer in feat(qa): wire Crabline WhatsApp transport #95920 settles.

Next step before merge

  • [P1] Maintainer review should decide whether to accept the fail-closed runtime env validation; there is no narrow automated repair item after this review.

Security
Cleared: Cleared: the diff adds no dependency, workflow, secret, or package-resolution change, and it narrows a trusted env endpoint override to WebSocket URL schemes.

Review details

Best possible solution:

Merge the validation follow-up once maintainers accept the current-main-only fail-closed env semantics and leave broader QA Crabline wiring to its separate PR.

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

Yes, from source inspection: current main passes the env fallback through as a raw string, while Baileys constructs a URL from waWebSocketUrl during socket creation. The PR adds a focused invalid-env regression test, though I did not run local tests in this read-only review.

Is this the best way to solve the issue?

Yes, this is the narrowest maintainable layer for the remaining issue: validate the trusted env fallback in createWaSocket before it reaches Baileys, while preserving explicit low-level caller options.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is a MEMBER-authored PR with the maintainer label, so the external-contributor real behavior proof gate does not apply.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is a low-blast-radius WhatsApp QA/operator validation follow-up rather than an urgent user-facing channel outage.
  • merge-risk: 🚨 compatibility: The PR changes how a trusted runtime env override is accepted, turning invalid current-main values into an early failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this is a MEMBER-authored PR with the maintainer label, so the external-contributor real behavior proof gate does not apply.
Evidence reviewed

PR surface:

Source +15, Tests +19. Total +34 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 18 3 +15
Tests 1 19 0 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 37 3 +34

What I checked:

  • Root policy read: Root AGENTS.md was read fully; its ClawSweeper policy treats env/config fallback and stricter validation as compatibility-sensitive review surfaces. (AGENTS.md:29, 5f60724b6d7b)
  • Scoped extension policy read: The scoped extensions policy was read and keeps bundled plugin runtime behavior inside the plugin boundary, which matches this WhatsApp-local validation change. (extensions/AGENTS.md:1, 5f60724b6d7b)
  • Current main behavior: Current main already reads explicit opts.waWebSocketUrl before the env fallback and passes the selected value to Baileys without env URL validation. (extensions/whatsapp/src/session.ts:184, 5f60724b6d7b)
  • PR head validation: The PR head adds resolveEnvWaWebSocketUrl, parses the env fallback with new URL, rejects non-ws:/wss: protocols, and keeps explicit options ahead of env fallback. (extensions/whatsapp/src/session.ts:136, 8a9e23f3d93a)
  • Regression coverage in diff: The PR adds tests for invalid env values and explicit-option precedence over an invalid env value. (extensions/whatsapp/src/session.test.ts:449, 8a9e23f3d93a)
  • Baileys dependency contract: Baileys 7.0.0-rc13 declares waWebSocketUrl: string | URL, defaults it to wss://web.whatsapp.com/ws/chat, and constructs a URL from the configured value in socket creation.

Likely related people:

  • RomneyDa: Authored the merged WhatsApp WebSocket override and this validation follow-up, so they are the most direct owner for the env fallback behavior. (role: feature owner and recent area contributor; confidence: high; commits: 0deddfa20428, 8a9e23f3d93a; files: extensions/whatsapp/src/session.ts, extensions/whatsapp/src/session.test.ts, src/infra/dotenv.test.ts)
  • steipete: Recent history shows focused WhatsApp session/proxy/runtime-boundary work adjacent to the socket and proxy paths touched by this PR. (role: recent adjacent contributor; confidence: medium; commits: 380a39626687, 30a94dfd3b7c, 0195da6b0eda; files: extensions/whatsapp/src/session.ts, extensions/whatsapp/src/session.test.ts)
  • scoootscooob: Moved the WhatsApp channel implementation into extensions/, establishing the current plugin ownership boundary for this session code. (role: introduced current extension placement; confidence: medium; commits: 16505718e827; files: extensions/whatsapp/src/session.ts, extensions/whatsapp/src/session.test.ts)
  • Agustin Rivera: Authored nearby workspace dotenv hardening that protects OPENCLAW_* runtime-control env vars from untrusted workspace .env files. (role: dotenv trust-boundary contributor; confidence: medium; commits: dbfcef319618, dafcaf9d69d2; files: src/infra/dotenv.ts, src/infra/dotenv.test.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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 29, 2026
@RomneyDa RomneyDa self-assigned this Jun 29, 2026
@RomneyDa
RomneyDa force-pushed the codex/whatsapp-websocket-url-env branch from 7693d0f to 8a9e23f Compare June 29, 2026 17:40
@RomneyDa RomneyDa changed the title Allow WhatsApp WebSocket URL override fix(whatsapp): validate WebSocket URL env Jun 29, 2026
@RomneyDa RomneyDa changed the title fix(whatsapp): validate WebSocket URL env harden WhatsApp WebSocket URL override Jun 29, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 29, 2026
@RomneyDa
RomneyDa merged commit 2ec6708 into main Jun 29, 2026
124 of 133 checks passed
@RomneyDa
RomneyDa deleted the codex/whatsapp-websocket-url-env branch June 29, 2026 17:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 30, 2026
QiuYuang pushed a commit to QiuYuang/openclaw that referenced this pull request Jul 1, 2026
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 3, 2026
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 maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

1 participant