Repository navigation
fix(macos): app quits with "Client credentials unavailable" after an in-place update while the previous Gateway service is running - #187000
Conversation
An in-place app update leaves the previous build's app-managed Gateway service running. Its state lease makes this build's client credential migration fail, so the app quit before post-update replacement ran. Startup now stops the stale service, prepares credentials, then installs the service on this build's runtime.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThe macOS app replaces an eligible previous-build Gateway service before preparing client credentials during startup. Example: Replace OpenClaw 2026.10.8 in place while its app-managed Gateway service is running.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR: it fixes a current macOS upgrade failure, addresses the earlier policy and custody findings, and now supplies production-path reassignment evidence; no actionable introduced defect remains. Priority: P0 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherNative app startup calls the bundled CLI’s credential migration owner before admitting credential consumers; the new orchestration uses existing Gateway service owners to release state custody and publish the replacement runtime. flowchart TD
A[Mac app startup] --> B[Inspect service and update policy]
B --> C[Stop eligible previous service]
C --> D[Prepare client credentials]
D --> E[Install bundled Gateway runtime]
D --> F[Restore previous service on failure]
E --> G[Continue startup and health recovery]
Technical reviewBest possible solution: Land the focused startup ordering repair using the existing migration, service-custody, update-policy, and post-update recovery owners. Do we have a high-confidence way to reproduce the issue? Current-main startup ordering and Doctor’s root-gated service handling support the reported contention path, corroborated by the author’s packaged stable-upgrade control; no target code was executed during this review. Is this the best way to solve the issue? The smallest complete repair must release the eligible old service before credential migration and install the matching runtime afterward; this implementation reuses the existing owners without adding configuration or changing operator-selected update policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d34d855440a7. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +116, Tests +84, Docs +3. Total +203 across 5 files. Added test files: 1. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 29, 2026, 4:12 AM ET / 08:12 UTC (Revision 4). |
…ice replacement Startup replacement now uses the managed repair gate shared with setup and post-update repair, so extended-stable and channel install policies keep their Gateway.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…cement Stop, restore and install now carry the service authority captured at detection and recheck the managed update authority before dispatch, so a service the operator reassigns while this build seeds or migrates is refused instead of stopped.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…in-place update while the previous Gateway service is running (openclaw#187000) * fix(macos): replace stale Gateway service before credential startup An in-place app update leaves the previous build's app-managed Gateway service running. Its state lease makes this build's client credential migration fail, so the app quit before post-update replacement ran. Startup now stops the stale service, prepares credentials, then installs the service on this build's runtime. * fix(macos): keep operator-selected Gateway versions during stale service replacement Startup replacement now uses the managed repair gate shared with setup and post-update repair, so extended-stable and channel install policies keep their Gateway. * fix(macos): keep detected Gateway service custody through stale replacement Stop, restore and install now carry the service authority captured at detection and recheck the managed update authority before dispatch, so a service the operator reassigns while this build seeds or migrates is refused instead of stopped.
Carry the reviewed Peekaboo snapshot ownership, stale-service startup, remote dashboard base-path, requester reconnect, timeout outcome, typed authentication, and predecessor-stop attribution fixes. Keep Android Talk and the stable-Bun service cutover separate until main-first disposition. Adapted source provenance: - #172116: 7861f59 - #187000: 96ceb48 - #185141: 292d171 - #180200: e937051 - #180247: 054516f - #128175: e83fcca - #187104: f8d52ec Reviewed patch: 745077ecb0347992e605b58a42d2f82becb46c350b0c7d7de449f90d055110ff All 69 postimages verified; 67 reuse the reviewed corrected full candidate. Existing focused evidence retained; full release qualification remains pending. Co-authored-by: RomneyDa <[email protected]>
Related: #156712
What Problem This Solves
Fixes: the macOS app quits at launch with "Another OpenClaw process is using your data" / "Client credentials unavailable. Run openclaw doctor --fix before reopening the app." when it is updated in place (reproduced from the latest stable, 2026.10.8, and from 2026.10.7) while the previous build's app-managed Gateway LaunchAgent service is still running.
User Impact
User impact: after an in-place update, the app now starts normally. The Gateway service moves to the new build's runtime, client credentials are migrated, and existing config and cron jobs are kept. Users no longer have to run
openclaw doctor --fixby hand. Normal launches, where the installed service already matches this build, are unchanged.Operators who chose their Gateway version keep it: with
update.channel = extended-stableor a channel install policy (stable,beta,dev), startup does not replace the service. This is the same gate setup and post-update repair already use. In that case startup behaves as it does today: the credential step can still fail while the old Gateway runs, and replacing the operator-pinned Gateway without consent would be worse. This is an accepted edge case.Why This Change Was Made
At launch, the app prepares client credentials before anything that replaces the service (
ConnectionModeCoordinator.apply,PostUpdateController). Stable builds up to and including 2026.10.8 have noclient/credentials.sqlite, so preparation isrequired.doctor --client-credentialsdeliberately does not control services: it callsbeginDoctorMaintenance({ root: null }), so the stop branch gated onparams.rootnever runs. Its state acquire then runs into the old Gateway's state-ownership lease and throwsGatewayStateOwnerContentionError. The app then terminates, so the post-update replacement never runs.The CLI's own refusals force the order:
gateway installrefuse.gateway installstill refuses until credentials are migrated ("Client credentials require backed-up migration custody").At startup the app now detects an app-managed service pinned to a different build's runtime, provided
CLIInstallPrompter.managedRepairGatesOpenallows a managed repair. It then:Stop, restore and install all carry the service custody captured at detection (
expectedServiceAuthority) and recheckserviceUpdateAuthorityErrorbefore dispatch. So a service the operator reassigns while this build seeds its runtime or migrates credentials is refused instead of stopped or overwritten.If credential preparation fails, the app restarts the previous service and the error surfaces as before. If the install fails, the failure is logged and startup continues, because credentials are valid and
PostUpdateControllerstill owns the retry. The CLI is unchanged.Stopping only, without the install, was tried and rejected. Credentials migrated, but the app then kept retrying "gateway ensuring launchd" through the stale stable CLI, and the Gateway stayed down.
Evidence
Reproduction from the latest stable (isolated profile
p178719; never the liveai.openclaw.gatewayor~/.openclaw).OpenClaw-2026.10.8-arm64.dmg(sha2567974be75…a3e899), with its app-managed service seeded with a custom timezone and a cron job..appbundle in place with the candidate build and launch it, with no manual steps.main(2026.10.8). The control build has the four changed files reverted.Before the fix (
main, 2026.10.8), red:After the fix, green (first run at 396f68c; rerun at 3f4cc92 with detection-time custody, same result: service moved in 20 s, credentials present, timezone and cron kept, control channel connected):
Service reassigned after detection, through real process dispatch. These runs use the same isolated seeded upgrade from stable 2026.10.8, with an app packaged from clean
3f4cc925(build2026.10.8-3f4cc9259730-…, release configuration, no DEBUG interception). Partway through startup, an "operator" rewrites~/Library/LaunchAgents/ai.openclaw.p178719.plist: same label, plus anEnvironmentVariables.OPENCLAW_PROOF_OPERATORkey. The rewrite is triggered by real effects, not sleeps.Before stop. The trigger is the new build's runtime seed directory appearing, which happens after detection read the service. The operator also reloads the service:
The operator's service is not stopped: the same pid is still listening and the plist is unchanged. Startup then ends in the existing credential-recovery surface. This is the accepted edge case: an operator who reassigns the service during startup gets "retry", and their service is left alone.
After credential preparation, before install. The trigger is the old Gateway's listener going away after the app's stop:
Credentials are migrated, the install is refused, and the operator's plist bytes are kept. The service is not moved to the new runtime.
The same flow starting from stable 2026.10.7 was also red on
main(443530a) and green with the first commit, twice: the service moved to the new runtime in 20 s, and the timezone and cron job survived.Tests:
swift test --filter "stale service replacement keeps|StaleGatewayServiceReplacementTests|ClientCredentialStartupTests|UpdateOrchestrationTests"passes (35 tests, at 3f4cc92). The new tests pin:The Gateway service changed before dispatch; retry., no daemon command recorded), while an unchanged service gets exactlystop --force. This test fails without the captured authority: the reassigned service receives the stop;exactpolicies, and rejectingextended-stable,betaandstable.Not covered:
ensuring launchdretries (a later owner) ran through the installed stable CLI and failed. They did not rewrite the operator's plist..localgate and was not exercised..DS_Storefiles insrc/infra/package-dist-inventory.ts. A straydist/.DS_Storeotherwise breaks the inventory/tarball check. This touches build tooling only, not the app code under test.