Repository navigation
fix(doctor): prevent catalog imports beside stored SecretRefs - #179802
Conversation
Preserve stored API-key and token references when importing generated model catalog credentials, including inherited references and changes during the repair prompt. Keep explicit configured literal credentials eligible for migration and use the auth writer's current shared-store view. Supersedes #179195; thanks @ensignwesley. Co-authored-by: Wesley <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 554084ee59
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| inheritedStore = sharedStore; | ||
| const effectiveStore = sharedStore | ||
| ? mergeAuthProfileStores(sharedStore, localStore) |
There was a problem hiding this comment.
Preserve the relocated shared-store environment
When params.env.OPENCLAW_AGENT_DIR relocates a legacy shared auth store and a SecretRef is added while the repair prompt is pending, this locked recheck reads the wrong shared store: only stateDir is passed to updateAuthProfileStoreWithLock, and its write preparation explicitly clears OPENCLAW_AGENT_DIR. Consequently sharedStore points at the default main-agent path, so a child catalog can still import the stale plaintext key beside the newly added reference. Pass the complete supplied environment through the locked writer (or otherwise resolve the shared owner from it) before using this view.
Useful? React with 👍 / 👎.
|
Landing despite one red job: |
…efs (openclaw#179802) Doctor guarded config-level SecretRefs but not references stored in the auth store, so it could write plaintext model credentials beside them. Generated catalog credentials are now checked against the auth writer's effective store; explicitly configured keys still migrate. Supersedes openclaw#179195, thanks @ensignwesley. Co-authored-by: Wesley <[email protected]>
…efs (#179802) Doctor guarded config-level SecretRefs but not references stored in the auth store, so it could write plaintext model credentials beside them. Generated catalog credentials are now checked against the auth writer's effective store; explicitly configured keys still migrate. Supersedes #179195, thanks @ensignwesley. Backport the bounded catalog-only repair for 2026.11.4. Preserve the existing provider env-marker helper and stable UTF-8 handling. Add real Doctor auth-phase regression coverage for shared and local references installed during confirmation. (cherry picked from commit 3f016b1) Co-authored-by: Wesley <[email protected]> Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes:
openclaw doctor --fixcan copy a stale plaintext model-catalog key into a new auth profile even when that provider already has an API-key or token SecretRef in its effective auth store.Supersedes #179195, thanks @ensignwesley.
User Impact
Doctor and update-time Doctor leave stored SecretRefs authoritative over generated catalog credentials, including references inherited by child agents. Explicit literal keys in
models.providersstill migrate, even beside an expired token reference. Existing references, source catalogs, and unrelated credentials remain intact; no configuration or schema changes are required.Why This Change Was Made
The migration distinguished config-level references but missed stored references. Catalog candidates now retain their source, and the locked writer rechecks the current effective store before importing them. It uses the auth writer's existing shared-store view, removing the stale caller-supplied snapshot and its extra read. The single-use env-marker predicate is folded into its owner. Production delta: +38/-39 (net -1); tests +89; docs +2.
This also addresses the useful finding on the original PR: a provider-wide guard must not discard an independently configured literal credential. Release-note context: Doctor no longer creates competing plaintext profiles from generated model catalogs beside stored SecretRefs; explicit configured credentials still migrate. Thanks @ensignwesley (#179195).
Evidence
8940c8134ad9, five new cases failed because a stale catalog credential was imported. The real built CLI reproduced the defect:doctor --fix --non-interactivereported one copied credential, and SQLite contained the original SecretRef pluscustom:models-json.HOME,OPENCLAW_STATE_DIR, and temporary directory.[email protected], used its real Doctor to import a legacy SecretRef, then added a stale generated catalog and ran the candidate Doctor on that state. Both exited successfully; the candidate retained only the reference profile. Normal missing-feature/setup warnings remained nonblocking. Original-state capture reported the host volume's staging-ancestor permissions; these were disposable synthetic states containing no operator data.tsgo, scoped oxlint, oxfmt,git diff --check, and Madge passed (zero cycles). Line-cap, assertion, SQLite dialect, test-timeout, mock-export, and Doctor-deprecation checks passed.check:changedwas replaced by the scoped checks above under the local gate budget. The separate database-worker inventory was stopped after roughly 80 s without output. The max-lines check reports inherited suppressions in unchangedui/src/pages/chat/components/chat-message.test.tsx,ui/src/pages/config/config-page-state.ts, andui/src/pages/sessions/sessions-page-state.ts; those files match the untouched base. PR CI supplies broad proof.The importing-consumer command was
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/infra/state-migrations.retained-deleted-agent.test.ts src/flows/doctor-health-contributions.auth-import-order.test.ts src/flows/doctor-health-contributions.test.ts src/commands/doctor-model-catalog-credentials.test.ts src/commands/doctor-agent-deletion-journal.test.ts --maxWorkers=1. Other focused commands includedOPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs src/commands/doctor-model-catalog-credentials.test.ts --maxWorkers=1,node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental,node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.commands-doctor.json --incremental, andnode --import ./scripts/tsx.mjs scripts/check-madge-import-cycles.ts. Live proof rannode openclaw.mjs doctor --fix --non-interactiveandpnpm dev doctor --fix --non-interactivewith isolated environment paths.