Skip to content

fix: write openclaw config atomically to preserve dashboard auth#2542

Closed
AhmedTMM wants to merge 7 commits intoOpenRouterTeam:mainfrom
AhmedTMM:fix/dashboard-auth-token
Closed

fix: write openclaw config atomically to preserve dashboard auth#2542
AhmedTMM wants to merge 7 commits intoOpenRouterTeam:mainfrom
AhmedTMM:fix/dashboard-auth-token

Conversation

@AhmedTMM
Copy link
Collaborator

Summary

  • Fixes the "Unauthorized" dashboard page introduced by feat: add Telegram and WhatsApp to OpenClaw setup picker #2523
  • The openclaw config set calls for browser and Telegram settings were re-serializing openclaw.json and dropping the gateway.auth.token field
  • Now all config (gateway auth, browser, channels) is built as a single JSON object and written once via uploadConfigFile

Test plan

  • Run spawn openclaw <cloud> — dashboard should open without "Unauthorized"
  • Select Telegram, enter a bot token — verify it appears in ~/.openclaw/openclaw.json
  • Select browser option — verify browser config appears in the same JSON file
  • bun test passes (1380/1380)

🤖 Generated with Claude Code

AhmedTMM and others added 7 commits March 12, 2026 00:49
Adds separate "Telegram" and "WhatsApp" checkboxes to the OpenClaw
setup screen:

- Telegram: prompts for bot token from @Botfather, injects into
  OpenClaw config via `openclaw config set`
- WhatsApp: reminds user to scan QR code via the web dashboard
  after launch (no CLI setup possible)

Updates USER.md with channel-specific guidance when either is selected.

Bump CLI version to 0.16.16.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instead of punting WhatsApp setup to "after launch", runs
`openclaw channels login --channel whatsapp` as an interactive SSH
session between gateway start and TUI launch. The user scans the
QR code with their phone during provisioning setup.

Flow: gateway starts → tunnel set up → WhatsApp QR scan → TUI launch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ahmed Abushagur <ahmed@abushagur.com>
The `openclaw config set` calls for browser and Telegram settings were
re-serializing openclaw.json and dropping the gateway.auth.token field,
causing the dashboard to show "Unauthorized" when auto-opened via tunnel.

Now all config (gateway auth, browser, channels) is built as a single
JSON object and written once via uploadConfigFile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds 40 new tests across 2 files:

openclaw-config.test.ts (30 tests):
- Gateway auth token written correctly and matches browserUrl
- Atomic config write (no `openclaw config set` commands)
- Browser config gated by enabledSteps
- Telegram bot token included/omitted based on input
- USER.md messaging channel content
- Tunnel config targeting port 18791

orchestrate-messaging.test.ts (10 tests):
- SPAWN_ENABLED_STEPS parsing and threading
- WhatsApp QR scan session triggered before agent launch
- GitHub auth gated by enabledSteps
- preLaunchMsg output behavior

Also adds SPAWN_TELEGRAM_BOT_TOKEN env var override for
non-interactive/CI Telegram setup (avoids prompt in tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

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

Security Review

Verdict: APPROVED
Commit: 3aa895e

Findings

No security issues found. This PR improves security by fixing the race condition where the gateway auth token was being dropped during config updates.

Positive changes:

  • [SECURITY FIX] Atomic config write prevents token loss (agent-setup.ts:388-389)
  • [GOOD] Credential handling uses JSON.stringify (no injection risk) (agent-setup.ts:388)
  • [GOOD] User input (Telegram token) properly sanitized via trim() (agent-setup.ts:341)
  • [GOOD] WhatsApp command is static string (no interpolation) (orchestrate.ts:259-261)
  • [GOOD] 40 new test cases verify token preservation and atomic writes

Tests

  • bash -n: N/A (no shell scripts changed)
  • bun test: PASS (40/40 tests passing)
  • Lint: PASS (0 errors from biome)
  • macOS compat: N/A (no shell changes)

Summary

This PR addresses issue #2489 by writing all OpenClaw config atomically in a single JSON upload, preventing the gateway auth token from being clobbered by subsequent openclaw config set calls. The implementation is secure with no injection risks, and comprehensive test coverage validates the fix.


-- security/pr-reviewer

@louisgv louisgv added the security-approved Security review approved label Mar 12, 2026
@AhmedTMM
Copy link
Collaborator Author

Fix merged directly into #2523 instead.

@AhmedTMM AhmedTMM closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-approved Security review approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants