fix(doctor): reconcile gateway service token drift after re-pair#18525
Merged
steipete merged 1 commit intoopenclaw:mainfrom Feb 16, 2026
Merged
Conversation
`openclaw doctor` audited gateway service runtime/path settings but did not check whether the daemon's `OPENCLAW_GATEWAY_TOKEN` matched `gateway.auth.token` in `openclaw.json`. After re-pairing or token rotation, the config token and service env token can drift. The daemon may keep running with a stale service token, leading to unauthorized handshake failures for cron/tool clients. Add a gateway service audit check for token drift and pass `cfg.gateway.auth.token` into service audits so doctor treats config as the source of truth when deciding whether to reinstall the service. Key design decisions: - Use `gateway.auth.token` from `openclaw.json` as the authority for service token drift detection - Only flag mismatch when an authoritative config token exists - Keep fix in existing doctor service-repair flow (no separate migration step) - Add focused tests for both audit mismatch behavior and doctor wiring Fixes openclaw#18175
ab9860f to
94e37b2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OPENCLAW_GATEWAY_TOKEN) can drift fromgateway.auth.tokeninopenclaw.json.gateway-token-mismatch) and wired doctor service audit to passcfg.gateway.auth.tokenas the expected authoritative token.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
openclaw doctornow detects when the installed gateway service token env is stale or missing compared togateway.auth.tokenin config, and offers the existing service repair/update flow.Security Impact (required)
No)Yes)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
gateway.auth.mode=token,gateway.auth.token=<redacted>Steps
gateway.auth.tokenwith a new value inopenclaw.json.OPENCLAW_GATEWAY_TOKENenv value.Expected
Actual
gateway-token-mismatchand doctor uses config token as source of truth when rebuilding service environment.Evidence
Attach at least one:
Tests:
pnpm test src/daemon/service-audit.test.ts src/commands/doctor-gateway-services.test.tsHuman Verification (required)
What you personally verified (not just CI), and how:
pnpm build && pnpm check && pnpm testsuite runCompatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
src/daemon/service-audit.tssrc/commands/doctor-gateway-services.tsRisks and Mitigations
AI-assistance disclosure:
Greptile Summary
Adds token drift detection to the gateway service audit, treating
gateway.auth.tokeninopenclaw.jsonas the authoritative source. Whenopenclaw doctorruns, it now compares the service'sOPENCLAW_GATEWAY_TOKENenvironment variable against the config token and flags mismatches for repair.gatewayTokenMismatchaudit code to detect when service token differs from config tokenauditGatewayTokenfunction performs the comparison (only when expected token is set)maybeRepairGatewayServiceConfignow passescfg.gateway?.auth?.tokento auditConfidence Score: 5/5
Last reviewed commit: ab9860f
(2/5) Greptile learns from your feedback when you react with thumbs up/down!