Repository navigation
fix(auth): normalize legacy credentials through Doctor - #162958
Conversation
|
🦞👀 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. Reviewed October 1, 2026, 5:38 PM ET / 21:38 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR moves legacy credential conversion into Doctor, preserves migration backups and account selections, and makes runtime readers require canonical credential fields. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness✅ Ready for maintainer review This remains a useful landing candidate: current main still needs the repair, and the updated evidence addresses the previous review blockers. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherDoctor repairs stored credentials before updates and runtime authentication consume them. It coordinates SQLite stores, legacy JSON imports, and account references so canonical credentials remain attached to their existing owners. flowchart TD
A[Stored credentials and legacy JSON] --> B[Doctor repair planning]
B --> C{Account mapping safe?}
C -->|Yes| D[Repair fields and account references]
C -->|No| E[Repair fields and defer mapping]
D --> F[Verified backups and guarded writes]
E --> F
F --> G[Canonical runtime authentication]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +378, Tests +802, Docs +37. Total +1217 across 19 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep credential conversion with Doctor and its existing storage owners, preserving verified recovery and account identity before canonical runtime reads. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main skips SQLite credential-field repair when no profile IDs require renaming. This review did not execute a reproduction; the supplied evidence records regression red/green results. Is this the best way to solve the issue? Yes. Moving conversion into the existing migration owner, with verified backups and deferred unsafe mappings, provides a complete cutover without another runtime compatibility reader. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 63a514d927e8. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
|
Landed (squash |
…or normalization (openclaw#162958) Setup and auth flows persisted plaintext provider tokens and lost rotation state when Doctor normalized legacy auth profiles. Credentials are now normalized by the Doctor owner only, with credential values and rotation state preserved, verified migration backups, and no runtime fallback reader for the legacy plaintext shape. Supersedes openclaw#162685 (thanks @yashas-13 for the original report and candidate). Refs openclaw#162685
What Problem This Solves
Fixes legacy credential fields remaining in SQLite after Doctor, including when a conflicting account alias would otherwise stop independent credential repairs.
Supersedes #162685. Thanks @steipete for the original migration implementation; its commit and attribution are retained.
User Impact
Doctor and update-time repair persist canonical credential fields before runtime reads, with verified private backups. Existing accounts, explicit order, rotation state, and unresolved account selections stay attached to their owners. A conflicting alias defers only that mapping, allowing safe field repairs and JSON imports to continue. Existing canonical credentials retain precedence.
The installed updater runs candidate Doctor before activation. The published-driver proof below exercises that first hop. There are no new configuration or CLI options, dependencies, SQLite schema changes, suppressions, or baseline changes. Auto-merge is off.
Why This Change Was Made
The old runtime reader converted legacy fields on every read, while Doctor returned early when no profile IDs needed renaming. The original PR moved conversion into Doctor, but review found that stale alias/receipt early returns could still bypass field normalization before JSON import. This replacement removes only rejected mappings and strengthens the existing import recovery regression.
Backups, database-generation and source-row revalidation, and original/normalized receipt fingerprints preserve recovery across independently committed owners. Existing SQLite repairs retain unknown metadata and opaque rotation bytes. JSON import retains its existing canonical projection and archives the exact original source. Repeated Doctor leaves auth rows, receipts, and backup inventory unchanged.
Production: +976/-598 (net +378). Gross totals include relocated code. Tests: +831/-29 (net +802). Docs: +37. Follow-up test changes extend existing fixtures without adding cases.
Config, credential storage, and commit authority retain their existing owners. There is no new credential store, state writer, schema, or runtime compatibility owner.
Runtime-reader audit: no fallback reader remains for the migrated credential-field encodings.
loadPersistedAuthProfileStoreandloadPersistedSharedAuthProfileStoreconsume the canonical parser inpersisted.ts. Convertiblemode,apiKey/api_key, and object-valued key/token fields produce theopenclaw doctor --fixerror instead of runtime conversion. Conversion helpers serve Doctor/import/receipt/session repair. The sole non-Doctor diagnostic consumer,readLegacyAuthProfileProviders, returns bounded provider names for migration-refusal reporting only; it cannot publish or resolve credential material.Canonical
gateway.auth.tokenfile SecretRefs remain valid configuration. Native app handling of those refs, absent credentials in a deliberately clean state directory, and optional OAuth refresh behavior involve separate owners and are not claimed fixed here.Evidence
Final merged PR head:
f165958b00229c0475e18f557d5aea5742812381. Individual proof runs below retain their tested source heads.pnpm test src/secrets/apply.test.ts --maxWorkers=1on the exact pushed head took 31.31 s wall; Vitest duration 29.37 s, about 10 s test work. The previously failing preservation case passed in 309 ms. Its old fixture wrotemode: "oauth"into canonical SQLite while already expectingtype: "oauth"; the final commit fixes only that input and retains every assertion.node scripts/check-changed.mjs --base b4836fcbb48728ecd493ec9276e67b68c0e022d9 --head fbd3ed117834bf67dccb09be3499bd9c3331a44fpassed on fresh Blacksmith Testboxtbx_01m3wm9821jnhag59bfzet1kms(run), after fetching that SHA andpnpm install --frozen-lockfile. Node 24.19.0, pnpm 12.5.1. All 27 test typecheck groups, all dead-export scans, and all selected guards passed; lint reported zero warnings/errors and the runtime import-cycle scan reported zero cycles. No local source sync, suites, builds, or typechecks.c8be6faef7dc73e4a6f1f899fd9bb0625e06813a, the strengthened import regression failed against the original implementation with the expected migration-required error (106 ms test time). Restoring the fix passed all 8 import-recovery cases in 28.68 s wall. The original PR's 208 tests across 11 files also passed; its full gate exposed the line-cap and obsolete-export gaps fixed here.c8be6faaccounted for all 130 direct/barrel/mock importers: 128 files passed, one fixture failed, one live-provider file skipped; 2,207 cases passed, one failed, one skipped. The corrected fixture now passes as recorded above. Reporter/routing limitations were handled by continuing only unstarted files, preserving completed evidence. No failed test was retried to obtain green. After the export cleanup at production headf8b0adce, the affected worker file passed all 13 cases in 32.78 s wall (16.77 s Vitest duration, about 7.9 s test work).Waived slow-test follow-up
The maintainer explicitly waived the pre-existing
src/commands/doctor.auth-profile-consumers.e2e.test.tsslow-test STOP for this lane. Its “unoccupied destination and padded references” case took 44.306 s of test time; the other cases took 28.895 s and 21.929 s. Each runs the full built Doctor CLI twice, six boots overall. Shared compiler preparation had finished, so these are actual test costs.Follow-up: profile Doctor startup and the test composition, then reduce cost while preserving migration, repeated-run idempotence, and interactive entrypoint proof. The exact child-process hotspot is not yet isolated. No timeout increase, retry, skip, or weaker assertion was introduced.
Published-driver × candidate
PASS for production head
f8b0adce50b1790b975af2ea11bf552a0096b4e1on Blacksmith run, leasetbx_01m3wj80nvd142dn0pcpe4cddb. The final PR head also replaces the duplicatedOPENAI_PROVIDER_IDliteral with the existing shared"openai"constant in two production files, alongside the one-line test fixture correction. Migration and backup logic are unchanged; the update result remains attributed tof8b0adce50b1790b975af2ea11bf552a0096b4e1.Published
[email protected]ranopenclaw update --tag file:/tmp/l1374-package/candidate.tgz --yes --json --no-restart --timeout 1200, returnedstatus: okin 153.92 s, and installed the exact candidate build. Doctor, lint, config, plugins, recovery, and Gateway startup checks exited 0. Canonical packaging took 477.74 s. Candidate SHA-256:136b1d8911fd1a23598dbf75b3492fcdc18abcea26e03b2c2c6118f0150ffb59.Six legacy SQLite credential forms normalized and one JSON profile imported. Original IDs, explicit order, last-good selection, and rotation bytes survived. Backup retained original credential fields; JSON archive retained exact bytes with a completed receipt. Repeated Doctor (8.24 s) changed no auth rows, timestamps, receipts, or backup inventory. Installed
models status --json(1.05 s) reported seven profiles, provider healthok, and the original effective order. Canonical SDK reads/order and inline resolution passed; SecretRefs retain their activated-snapshot requirement. No live provider request, macOS app proof, or OAuth refresh was attempted.No merge, auto-merge, release, or package publication was performed.
The resumed lease was released after verification. The pre-existing slow-test follow-up is explicitly waived for this PR; all requested readiness checks are complete.