Skip to content

fix(cli): surface model auth refresh failures - #131968

Merged
obviyus merged 7 commits into
mainfrom
fix/fix-cli-surface-model-auth-refresh-failu
Sep 9, 2026
Merged

obviyus merged 7 commits into
mainfrom
fix/fix-cli-surface-model-auth-refresh-failu

Conversation

@vyctorbrzezowski

@vyctorbrzezowski vyctorbrzezowski commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

CLI model-auth changes could leave a running Gateway using stale credentials while the command appeared successful. Connected refresh failures were hidden, a forced re-login did not publish its committed purge when replacement login failed, and remote clients received recovery instructions for the wrong host.

Closes #131944

Why This Change Was Made

The shared CLI refresh helper distinguishes local and remote targets, preserves silent auth-refresh handling when no local Gateway listens, and reports a saved change separately from a failed runtime refresh. Remote and tunnel targets receive guidance for the Gateway host.

A forced re-login validates the provider and method, commits the purge, and attempts refresh before replacement login. Explicit Gateway auth-refresh preparation failures return UNAVAILABLE. Ordinary last-good reads and owner-generation retry behavior remain intact.

The connected failure regression shares the existing Gateway auth-refresh dispatch suite. This removes the extra test root that broke the unchanged CI boundary limit while retaining the faulting reader, exact read count, response code and error message. The three existing generation and admitted-run cases remain in that suite.

The required merge conflict retains the current credential-persistence owner and the refresh warning assertion. All five commits from @vyctorbrzezowski are preserved. No configuration option, database schema or protocol version is added.

User Impact

  • Local auth writes remain usable while the Gateway is offline.
  • Connected refresh failures produce a visible restart action after the saved change.
  • Remote targets direct the operator to the Gateway host.
  • A committed force purge is published before replacement login can fail or be cancelled.
  • Explicit refresh cannot acknowledge stale authentication after preparation fails.

Evidence

  • CI run 34306787889 passed for c7fbc2283c4f34f060ef08d09acb74ca00b315d1, including the required aggregate gate, typechecks, lint and additional-boundary check.
  • The connected Gateway suite passed all four cases: admitted-run generation stability, waiter cancellation without cancelling shared publication, rejection without stale projection reuse, and explicit refresh returning UNAVAILABLE after an injected auth-store failure. The CLI force-login and prepared-auth error/supersession siblings also passed in this run.
  • The runtime artifact from that CI run was exercised through the built CLI. Its build commit is the CI merge be2ccb6a0fdd4959cabb23365d40fa5b7027b135; its full source tree matches the PR head. The original build stamp is retained.
  • Independent source-blind acceptance ran one fresh synthetic session with nine CLI outcomes. It confirmed offline credential persistence with a separate read, connected rejection with a generic restart warning, remote and explicit-URL host guidance without auth-refresh mutation, invalid-method credential preservation, and committed purge/refresh before interactive login cancellation with an empty profile list afterward. All four CLI clauses passed; no retry was used.
  • Native formatting and the normal staged-content hook passed for the test correction. Both changed test files also passed formatting after conflict resolution.
  • The historical built baseline saved a synthetic credential and cleared auth order while an unavailable Gateway produced no refresh warning. It retains its original build identity. The contributor's earlier 350 focused passes remain historical evidence at 2330d5f8f9670de79fdba3ce05f143db154d7a97.

Two native source-mode attempts timed out before producing a test result; neither is counted as a pass. CI supplied the missing connected-suite coverage. Compiled-fixture setup failures were retained and corrected at their observed status-preflight and terminal-size boundaries. Completed proof was reused.

Scope and Limits

The compiled CLI acceptance uses bundled OpenRouter and synthetic isolated state with an authenticated Gateway error fixture. It does not claim live provider authentication or inference. Gateway failure, ordinary-read and generation behavior are covered separately by the actual connected Gateway CI suite and source review. The independent report retains the absence of a separate auth-order read and raw fixture-response/configuration exports.

The CLI can also emit an existing installed-service discovery warning in the isolated environment. That warning is distinct from auth-refresh failure and was not hidden or treated as a failed credential save.

The authorized procedural owner-review exception is recorded for this exact head. Correctness, security, proof and required CI gates remain in force.

Production: +55/-18, net +37. Tests: +241/-38, net +203. The production growth owns shared target classification and actionable failure output; the redundant connected-server fixture was removed.

@vyctorbrzezowski
vyctorbrzezowski requested a review from a team as a code owner August 28, 2026 17:31
@vyctorbrzezowski vyctorbrzezowski self-assigned this Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 28, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 8, 2026, 11:58 PM ET / September 9, 2026, 03:58 UTC (Revision 8).

ClawSweeper review

What this changes

Makes model-auth commands distinguish saved credentials from failed Gateway refreshes, give host-specific recovery guidance, and refresh committed credential purges before replacement login.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR remains useful: current main still suppresses refresh failures, and the related merged auth-order fix does not replace it. No blocking code defect was found. The posted owner-review exception still needs verification under repository policy.

Priority: P1
Reviewed head: c7fbc2283c4f34f060ef08d09acb74ca00b315d1
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful boundary coverage and no blocking code finding; ownership verification is a separate landing gate.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its captured body reports built-CLI outcomes for persistence, warnings, remote rejection, and purge cancellation; the verified CI run supplements this with connected Gateway failure and generation coverage. No unresolved material authority expansion requires additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its captured body reports built-CLI outcomes for persistence, warnings, remote rejection, and purge cancellation; the verified CI run supplements this with connected Gateway failure and generation coverage. No unresolved material authority expansion requires additional final-effect proof.
Evidence reviewed 8 items Current main and release still need the fix: The refresh helper on fetched main and the supplied latest release commit catches every refresh failure without reporting it.
Introduced behavior and production boundary: The shared helper reports failed refresh separately from successful persistence, restricts refresh to the configured local shared-auth target, and suppresses only an unconnected local ECONNREFUSED. The force-login caller refreshes after the committed purge and before replacement authentication. These are OpenClaw-owned Gateway and credential-publication paths; the changed behavior does not depend on the Codex runtime contract.
Explicit refresh compatibility boundary: Explicit refresh propagates preparation failures through the existing UNAVAILABLE response wrapper. Ordinary reads still use the published snapshot, and catalog generation supersession still reacquires the owner. Main retains both swallowed-error paths.
Findings None None.
Security None None.

How this fits together

Model-auth commands save credentials locally and ask the running Gateway to refresh its prepared authentication state. The Gateway publishes that state for subsequent requests and returns refresh outcomes to the CLI.

flowchart TD
  A[Model auth command] --> B[Save local credentials]
  B --> C[Classify Gateway target]
  C --> D[Local authenticated refresh]
  C --> E[Remote host guidance]
  D --> F[Prepare authentication state]
  F --> G[Publish refreshed state]
  F --> H[Report refresh failure]
Loading

Decision needed

Question Recommendation
Can the recorded exception satisfy the owner-review requirement for the Gateway auth-refresh failure contract, or should a listed secops owner explicitly accept it? Obtain listed-owner acceptance: Have a listed secops owner accept the explicit-refresh error behavior for this head.

Why: Repository policy requires listed-owner involvement or verified organization-owner direction; the comment alone does not establish either.

Before merge

  • Resolve merge risk (P1) - Clients explicitly requesting auth refresh can now receive UNAVAILABLE where they previously received stale success; operators may need to repair authentication and retry or restart the Gateway.
  • Resolve merge risk (P1) - The exact-head owner-review exception is recorded, but its qualifying authority could not be verified; listed-owner acceptance remains unresolved.
  • Complete next step (P2) - Obtain listed secops-owner acceptance or verify qualifying organization-owner authority for the recorded exact-head owner-review exception.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +37, Tests +203. Total +240 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 6 55 18 +37
Tests 8 241 38 +203
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 296 56 +240

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Accept truthful explicit-refresh errors (recommended)
    Record qualifying owner acceptance that explicit refresh may fail with UNAVAILABLE while ordinary reads and saved credentials remain usable.

Technical review

Best possible solution:

Retain successful local credential writes and truthful refresh outcomes, with owner acceptance of the explicit-refresh failure contract before landing.

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

Yes, from source: current main catches both CLI refresh rejection and Gateway preparation failures, allowing persisted changes to appear fully applied. This review did not execute target code.

Is this the best way to solve the issue?

Yes. The repair uses the existing shared refresh owner and explicit refresh request, preserves ordinary reads and generation retry, and needs no parallel API or new configuration mode.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b72b30249fd0.

Labels

Label justifications:

  • P1: Silent refresh failures can leave active agent workflows using stale credentials after an apparently successful auth change.
  • merge-risk: 🚨 compatibility: Existing explicit-refresh clients will observe an error instead of stale success when authentication preparation fails.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from the external-contributor proof gate. Its captured body reports built-CLI outcomes for persistence, warnings, remote rejection, and purge cancellation; the verified CI run supplements this with connected Gateway failure and generation coverage. No unresolved material authority expansion requires additional final-effect proof.

Evidence

What I checked:

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • yetval: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (7 earlier review cycles)
  • reviewed 2026-08-28T17:37:02.790Z sha 1b5ede9 :: needs changes before merge. :: [P2] Direct remote users to the Gateway-host recovery
  • reviewed 2026-08-29T11:57:18.219Z sha 1b5ede9 :: found issues before merge. :: [P2] Direct remote users to the Gateway-host recovery
  • reviewed 2026-09-04T17:59:11.723Z sha 7f68369 :: blocked before merge. :: none
  • reviewed 2026-09-04T19:03:27.872Z sha a3f476e :: blocked before merge. :: none
  • reviewed 2026-09-04T19:48:01.185Z sha 34dbced :: blocked before merge. :: [P3] Use the real shared-auth rejection class in these mocks
  • reviewed 2026-09-07T18:49:25.393Z sha 2330d5f :: blocked before merge. :: none
  • reviewed 2026-09-09T03:27:30.929Z sha c7fbc22 :: blocked before merge. :: none

@vyctorbrzezowski
vyctorbrzezowski marked this pull request as draft August 29, 2026 11:50
@vyctorbrzezowski
vyctorbrzezowski force-pushed the fix/fix-cli-surface-model-auth-refresh-failu branch from 1b5ede9 to 7f68369 Compare September 4, 2026 17:43
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime and removed agents Agent runtime and tooling labels Sep 4, 2026
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review September 4, 2026 17:49
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@vyctorbrzezowski
vyctorbrzezowski force-pushed the fix/fix-cli-surface-model-auth-refresh-failu branch from 7f68369 to a3f476e Compare September 4, 2026 18:55
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Sep 4, 2026
@vyctorbrzezowski
vyctorbrzezowski force-pushed the fix/fix-cli-surface-model-auth-refresh-failu branch from 34dbced to 2330d5f Compare September 7, 2026 18:43
@obviyus obviyus self-assigned this Sep 9, 2026
@obviyus

obviyus commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-admin-merge
pr: 131968
head: c7fbc22
scope: owner-review

@obviyus
obviyus merged commit bb63053 into main Sep 9, 2026
186 of 188 checks passed
@obviyus
obviyus deleted the fix/fix-cli-surface-model-auth-refresh-failu branch September 9, 2026 04:14
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
Keep local model-auth writes usable while the Gateway is offline, report connected refresh failures with host-specific recovery, and refresh a committed force purge before replacement login. Propagate explicit Gateway auth preparation failures while preserving ordinary reads and generation safety.

Reuse the existing connected auth-refresh suite for failure coverage and retain current credential persistence when resolving the required test conflict. All original contributor commits are preserved.

Validation: exact-head CI 34306787889 passed, including all four connected Gateway cases. Fresh independent compiled CLI acceptance passed offline persistence, connected rejection, remote/URL guidance, invalid-method preservation and purge-before-cancellation behavior. The scoped owner-review exception is recorded at openclaw#131968 (comment).

Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus

obviyus commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks @vyctorbrzezowski!

Proof: Exact-head CI and fresh independent compiled CLI acceptance passed. The connected Gateway suite passed its failure, admitted-run, waiter and rejection cases. Fresh local ClawSweeper review passed before guarded landing.

  • Bug: Auth changes could appear successful while Gateway refresh failures were hidden.
  • Fix: Preserve saved writes, report the correct recovery host, refresh committed purges before replacement login, and return truthful explicit-refresh errors.
Before After
Refresh failure could leave only success text. The saved change remains usable and a refresh failure gives a recovery action.
Failed replacement login could leave its committed purge unpublished. Refresh precedes replacement login, including cancellation.
Failed explicit refresh could return stale auth successfully. The client receives UNAVAILABLE; ordinary reads and generation safety remain covered.

The compiled acceptance uses synthetic credentials and an authenticated Gateway error fixture; it does not claim live provider login or inference. The authorized owner-review exception waived the procedural owner wait; correctness, security, proof and required CI gates remained in force.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

fix(cli): surface model auth refresh failures

2 participants