Skip to content

fix(doctor): surface the resume failure cause for interrupted auth-profile archives - #123459

Merged
steipete merged 1 commit into
openclaw:mainfrom
masatohoshino:doctor-auth-resume-error-cause
Aug 26, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
masatohoshino:doctor-auth-resume-error-cause

Conversation

@masatohoshino

Copy link
Copy Markdown
Contributor

Related: #123164

What Problem This Solves

Resolves a problem where openclaw doctor / openclaw doctor --fix users whose interrupted
auth-profile archive fails again on a later resume attempt cannot tell why it failed — the warning is
always the same generic sentence no matter which underlying cause fired.

Why This Change Was Made

maybeMigrateAuthProfileJsonStoresToSqlite (src/commands/doctor-auth-flat-profiles.ts) has three
sibling catch blocks around auth-profile migration steps. #123164 fixed the identical defect in the
sibling catch block that migrates shared legacy OAuth credentials, changing it from a bare catch {}
that dropped the error to catch (err) with `: ${String(err)}` appended. This PR fixes the
one remaining sibling
— the catch block wrapping resumePendingAuthProfileMigrationArchives, which
can throw for several distinct reasons (invalid receipt shape, target verification failure, lock
contention, SQLite failure, corrupt receipt JSON) — the same way. Migration behavior is unchanged;
only the diagnostic text changes.

Real behavior proof

Behavior addressed: maybeMigrateAuthProfileJsonStoresToSqlite's resume-pending-archive catch
block discards the caught error instead of surfacing its cause in the user-visible warning.
Real environment tested: real Node process, real SQLite state DB (via createOpenClawTestState,
layout: "state-only"), real function under test (maybeMigrateAuthProfileJsonStoresToSqlite)
driven with no mocking of the code path being proved. Not a full end-to-end reproduction: the
pending-migration-receipt row is seeded directly via the existing test-only helper
(recordAuthProfileMigrationImported, exposed by src/commands/doctor-auth-migration-receipts.ts
under globalThis[Symbol.for("openclaw.authProfileMigrationReceiptsTestApi")] when NODE_ENV=test —
the same seeding pattern src/commands/doctor-auth-migration-receipts.test.ts uses for this
function's other resume paths) rather than produced by killing a real doctor process
mid-migration.
Exact steps or command run after this patch: a standalone script sets NODE_ENV=test, seeds one
pending migration receipt with targetTable set to a value outside its 3-member union (so
resumePendingAuthProfileMigrationArchives's row-shape check throws
"invalid pending auth profile migration receipt"), calls the real
maybeMigrateAuthProfileJsonStoresToSqlite, and prints result.warnings — run once against the base
commit and once against this PR's head to produce the before/after captures below.

Before evidence (base c66d5d84db4d473bbbfb51cc6f14e82d61623ee6, production code exactly as it was before this PR's diff):

$ node --import tsx probe-resume-warning.mts
result.warnings = ["Could not finalize an interrupted auth profile archive; legacy sources were left for recovery."]

Evidence after fix (head aa58e5d08463f19ad95f642383b5992945a26231):

$ node --import tsx probe-resume-warning.mts
result.warnings = ["Could not finalize an interrupted auth profile archive; legacy sources were left for recovery: Error: invalid pending auth profile migration receipt"]

Observed result after fix: the warning string now ends with : Error: invalid pending auth profile migration receipt instead of a bare period.
What was not tested: the other 4 real throw causes inside resumePendingAuthProfileMigrationArchives
were not individually reproduced — the fix (${String(err)} on whatever was caught) is cause-agnostic,
so this one cause is representative, not exhaustive.
Proof limitations or environment constraints: temporary SQLite state dir under the OS temp directory,
not a real user state directory.

Evidence

Changed files: src/commands/doctor-auth-flat-profiles.ts (production, +2/-3, no new imports, no
logic change) and src/commands/doctor-auth-flat-profiles.test.ts (+44, one new regression test using
the same receipt-seeding approach as the proof above, inside vitest). Confirmed the test fails on
pre-fix code (matches the raw "before" capture above) and passes after the fix.

  • node scripts/run-vitest.mjs src/commands/doctor-auth-flat-profiles.test.ts — 52/52 pass (full file).
  • ./node_modules/.bin/oxfmt --check src/commands/doctor-auth-flat-profiles.ts src/commands/doctor-auth-flat-profiles.test.ts — All matched files use the correct format.
  • node scripts/run-oxlint.mjs src/commands/doctor-auth-flat-profiles.ts src/commands/doctor-auth-flat-profiles.test.ts — exit 0, no output.
  • pnpm tsgo:core — exit 0.
  • Codex autoreview (--mode local) — autoreview clean: no accepted/actionable findings reported.

Non-Scope

…ofile archives

maybeMigrateAuthProfileJsonStoresToSqlite discarded the error from
resumePendingAuthProfileMigrationArchives entirely, so the warning was always
the same generic string regardless of which of 5 distinct causes fired
(invalid receipt, target verification failure, lock failure, SQLite failure,
corrupt JSON). PR openclaw#123164 fixed the identical defect class in the sibling
shared-OAuth catch block 20 lines below in this same function, explicitly
modeling the fix on the third, already-correct sibling. This was the
unaddressed third catch block in that same family.
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Aug 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 8:54 PM ET / August 26, 2026, 00:54 UTC.

ClawSweeper review

What this changes

Adds the caught failure cause to Doctor’s interrupted auth-profile archive warning and covers that operator-visible diagnostic with a regression test.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for routine merge review: current main still drops the resume error cause, while this narrow PR restores it with focused regression coverage and no actionable patch defect found.

Priority: P2
Reviewed head: aa58e5d08463f19ad95f642383b5992945a26231

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused caller-boundary fix with credible direct SQLite before/after proof and no supported correctness finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR supplies before/after terminal output from the real migration function with a real temporary SQLite state database; the seeded receipt directly demonstrates the changed warning and observed cause.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR supplies before/after terminal output from the real migration function with a real temporary SQLite state database; the seeded receipt directly demonstrates the changed warning and observed cause.
Evidence reviewed 6 items Current-main defect: Current main catches archive-resume failures without binding the error and returns a fixed generic warning, so distinct recovery failures remain indistinguishable to the operator.
Owner boundary and caller: The recovery helper validates persisted pending receipts and can throw before Doctor returns early to preserve the recovery record; both the health flow and repair sequencing invoke the migration function.
Patch and regression coverage: The branch appends the caught error at the owning caller boundary; its test seeds one invalid pending receipt and asserts the returned warning includes the cause.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/commands/doctor-auth-flat-profiles.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs src/commands/doctor-auth-flat-profiles.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs src/commands/doctor-auth-flat-profiles.test.ts"

│
│  - Migrated auth profile JSON for
                                                 │
│    /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-U7mgFd/state/agents/main/agent/auth-profiles.json
                                                 │
│    into SQLite (archive:
                                                 │
│    /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-U7mgFd/state/agents/main/agent/auth-profiles.json.migrated-2026-08-26T00-56
-13.969Z-ca3d20fc-f720-4a2a-8e25-42ba0d14cc12).  │
│  - Migrated 1 OpenAI Codex auth profile(s) in
                                                 │
│    /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-U7mgFd/state/agents/main/agent/auth-profiles.json
                                                 │
│    to provider "openai".
                                                 │
│
                                                 │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─────────────────────────────────────────────────╯
│
◇  Auth profile SQLite migration ───────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                       │
│  - /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-A4Ic3u/state/agents/main/agent/auth-profiles.json  │
│    /                                                                                                                                  │
│    /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-A4Ic3u/state/agents/main/agent/auth-state.json     │
│  - openclaw doctor --fix imports legacy auth profile JSON into SQLite,                                                                │
│    verifies it, records a receipt, and archives the original bytes.                                                                   │
│                                                                                                                                       │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
│
◇  Doctor changes ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─────────────────────────────────────────────────╮
│
                                                 │
│  - Migrated auth profile JSON for
                                                 │
│    /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-A4Ic3u/state/agents/main/agent/auth-profiles.json
                                                 │
│    into SQLite (archive:
                                                 │
│    /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-A4Ic3u/state/agents/main/agent/auth-profiles.json.migrated-2026-08-26T00-56
-14.101Z-150763d1-1863-417e-9834-369f2735ce1f).  │
│  - Migrated 2 OpenAI Codex auth profile(s) in
                                                 │
│    /tmp/clawsweeper-live-proof-123459-CzWj8w/profile/tmp/openclaw-doctor-flat-auth-A4Ic3u/state/agents/main/agent/auth-profiles.json
                                                 │
│    to provider "openai".
                                                 │
│
                                                 │
├───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
─────────────────────────────────────────────────╯
│
◇  Auth profile SQLite migration ──────────────────────────────────────────────
… output truncated …

Assertions:

  • FAIL expect_output: 52 passed

How this fits together

Doctor runs auth-profile migration recovery before inspecting and repairing legacy credential stores. A failed archive resume stops further migration to preserve recovery state, and its warning is returned to Doctor’s operator output.

flowchart TD
  A[Doctor run] --> B[Auth-profile migration recovery]
  B --> C[Pending archive receipts]
  C --> D{Resume succeeds?}
  D -->|Yes| E[Continue migration]
  D -->|No| F[Preserve recovery state]
  F --> G[Warning with failure cause]
  G --> H[Operator output]
Loading

Before merge

  • Complete next step (P2) - This PR already owns the concrete repair; no separate automated repair lane is needed beyond normal exact-head CI and maintainer review.
Agent review details

Security

None.

PR surface

Source -1, Tests +44. Total +43 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 3 -1
Tests 1 44 0 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 46 3 +43

Review metrics

Metric Value Why it matters
Production vs regression coverage production −1 net; tests +44 net The diagnostic fix replaces a generic catch with a cause-bearing warning without production growth; the added lines are focused migration-recovery coverage.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-auth-flat-profiles.test.ts, serialized state: src/commands/doctor-auth-flat-profiles.test.ts, unknown-data-model-change: src/commands/doctor-auth-flat-profiles.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #123459
Summary: The related merged PR repaired the equivalent shared-OAuth warning but left this distinct pending-archive resume catch as remaining work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

  • Exact-head CI is still queued, so merge readiness remains contingent on GitHub’s required checks.

Maintainer options:

  1. Decide the mitigation before merge
    Land this caller-boundary diagnostic repair after exact-head checks pass, retaining the recovery-preserving early return and the existing sibling warning convention.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land this caller-boundary diagnostic repair after exact-head checks pass, retaining the recovery-preserving early return and the existing sibling warning convention.

Do we have a high-confidence way to reproduce the issue?

Yes—source establishes a current-main path: an invalid pending receipt throws during resume, and the caller converts it to a generic warning. The branch’s real SQLite before/after capture exercises that path, though this review did not execute it.

Is this the best way to solve the issue?

Yes. The caller that turns recovery failures into Doctor warnings is the narrowest owner for preserving the cause, and the change matches the two existing sibling handlers without altering migration or archive semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0036788055b5.

Labels

Label justifications:

  • P2: A bounded Doctor diagnostic defect affects recovery guidance but does not change migration behavior or create an urgent availability or security failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR supplies before/after terminal output from the real migration function with a real temporary SQLite state database; the seeded receipt directly demonstrates the changed warning and observed cause.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies before/after terminal output from the real migration function with a real temporary SQLite state database; the seeded receipt directly demonstrates the changed warning and observed cause.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged adjacent shared-OAuth diagnostic repair and recent shared-auth migration work in the same Doctor/auth-profile surface. (role: recent area contributor; confidence: medium; commits: ae148164d466, d2dad76ecde4; files: src/commands/doctor-auth-flat-profiles.ts, src/commands/doctor-auth-migration-receipts.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-14T04:14:01.484Z sha aa58e5d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T05:11:35.482Z sha aa58e5d :: needs maintainer review before merge. :: none
  • reviewed August 20, 2026, 1:48 AM ET / 05:48 UTC sha unknown :: needs maintainer review before merge. :: none

@masatohoshino

Copy link
Copy Markdown
Contributor Author

Reopening to re-trigger CI attach (known pull_request-open race).

@masatohoshino masatohoshino reopened this Aug 14, 2026
@masatohoshino
masatohoshino marked this pull request as ready for review August 14, 2026 05:09
@Takhoffman Takhoffman assigned Takhoffman and unassigned Takhoffman Aug 14, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 20, 2026
@steipete steipete closed this Aug 26, 2026
@steipete steipete reopened this Aug 26, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit 9c30c92 into openclaw:main Aug 26, 2026
518 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…ofile archives (openclaw#123459)

maybeMigrateAuthProfileJsonStoresToSqlite discarded the error from
resumePendingAuthProfileMigrationArchives entirely, so the warning was always
the same generic string regardless of which of 5 distinct causes fired
(invalid receipt, target verification failure, lock failure, SQLite failure,
corrupt JSON). PR openclaw#123164 fixed the identical defect class in the sibling
shared-OAuth catch block 20 lines below in this same function, explicitly
modeling the fix on the third, already-correct sibling. This was the
unaddressed third catch block in that same family.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants