openclaw - 💡(How to fix) Fix doctor --fix silently rotates gateway.auth.token on valid configs

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Interactive openclaw doctor --fix can silently regenerate gateway.auth.token even when a valid token is already configured, causing mass consumer disconnects.

Root Cause

runGatewayAuthHealth in doctor-health-contributions.ts generates a new random token whenever it detects auth is "off or missing a token." While the existing gate ((auth.mode !== "token" || !auth.token)) should prevent this when a valid token exists, the config-audit logs prove that interactive runs produce a new random token every time.

Code Example

if (auth.mode === "token" && auth.token && auth.token.length >= 32) return;

---

note("🔁 gateway.auth.token rotated; consumers will need to be restarted to re-read .env", "Gateway auth");
RAW_BUFFERClick to expand / collapse

Summary

Interactive openclaw doctor --fix can silently regenerate gateway.auth.token even when a valid token is already configured, causing mass consumer disconnects.

Root Cause

runGatewayAuthHealth in doctor-health-contributions.ts generates a new random token whenever it detects auth is "off or missing a token." While the existing gate ((auth.mode !== "token" || !auth.token)) should prevent this when a valid token exists, the config-audit logs prove that interactive runs produce a new random token every time.

Evidence

From production config-audit.jsonl over 7 days:

Date (UTC)CommandSize ΔVerdict
May 20 01:30doctor --non-interactive --fix+2542BInitial setup
May 20 22:41doctor --fix (interactive)+2542BSame input config → different output hash = rotated
May 24 22:27doctor --fix (interactive)+2527BRotated
May 27 08:03doctor --fix (interactive)+47BRotated (47 bytes fits a 48-char hex token)

Key finding: the May 20 22:41 run has the same previous hash as the 01:30 run but produces a different next hash at the same byte count. This confirms crypto.randomBytes(24).toString("hex") generates a new value on each invocation.

Impact

  • All gateway consumers that load the token at startup (long-running processes, systemd services, external scripts) lose connectivity silently
  • No warning is emitted when the token changes — discovery requires diffing config hashes

Fix Suggested

Add an early-return guard before the existing condition:

if (auth.mode === "token" && auth.token && auth.token.length >= 32) return;

And emit a visible warning when rotation does occur:

note("🔁 gateway.auth.token rotated; consumers will need to be restarted to re-read .env", "Gateway auth");

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING