Skip to content

fix: stop OAuth fallback after catalog discovery times out - #139924

Merged
shakkernerd merged 2 commits into
mainfrom
fix/catalog-auth-timeout
Sep 6, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
fix/catalog-auth-timeout

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #137120

Additional instructions

This PR uses a branch in openclaw/openclaw.

What Problem This Solves

Fixes an issue where users waiting for model discovery could have additional
accounts' OAuth credentials refreshed in the background after discovery had
already timed out. This happened when the first account's pending refresh later
failed and preparation advanced to the next candidate.

Why This Change Was Made

The catalog timeout already suppressed late catalog results, but its preparation
loop could not observe that discovery had ended. Carry the existing owner's
liveness state into that loop and close admission when the timer fires.

An already-started refresh is allowed to finish and persist its rotated token.
Normal fallback before timeout, account ordering, failure-outcome semantics and
provider SDK contracts are unchanged.

User Impact

Model discovery stops starting additional account refreshes after its timeout.
Late preparation still cannot start the catalog hook, while an in-progress token
rotation can finish safely. No configuration changes are required.

Evidence

Validated head: 4af27929a0718f0077eeedf57884172139528333.

  • The real planner regression fails on base 9e5bb4a3ecd03772156fdbf3201ab54af5c6be98
    because A's late failure starts B after timeout. Late-success and untimed
    fallback controls pass on that base.
  • All 63 affected tests pass on the final head in
    Blacksmith Testbox,
    including persisted rotation, scoped outcomes, static fallback, and refresh-queue
    lifecycle. The tests join the actual preparation before checking late work.
  • A separate runtime proof calls ensureOpenClawModelsJson with the real Chutes
    plugin and refresh owner, synthetic persisted accounts, and controlled HTTP
    grant/catalog responses. It verifies the following results and removes its
    isolated state and servers afterward:
Scenario Observed result
A fails after timeout Only A's refresh starts; B is unchanged; no catalog request or late outcome.
A succeeds after timeout A's rotated token persists; B is unchanged; no catalog request or late outcome.
A fails while discovery remains active B refreshes, its current token authenticates catalog discovery, and its model is published.
  • The runtime build and applicable changed-path gates pass. Unchanged core type
    graphs were reused from the preceding tested head after verifying that the only
    intervening change is the root test's fixture-presence assertion; final root-test
    types and remaining gates were rerun successfully.
  • Exact-head CI
    is green. Independent full-patch and fixture-correction reviews are clean
    through P2. No production findings remain.

@shakkernerd
shakkernerd requested a review from a team as a code owner September 6, 2026 08:07
@clawsweeper

clawsweeper Bot commented Sep 6, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 4:52 AM ET / 08:52 UTC.

ClawSweeper review

What this changes

Stops model discovery from starting another account’s OAuth refresh after timeout while allowing an already-started token rotation to finish.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main still permits OAuth preparation to advance after discovery times out. No introduced correctness defect was found, and the updated evidence resolves the previous validation hold.

Priority: P2
Reviewed head: 4af27929a0718f0077eeedf57884172139528333

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with meaningful regression controls and updated validation evidence; no actionable patch defect remains.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a repository MEMBER, so the external-contributor gate does not apply; the captured body additionally reports real planner/Chutes HTTP scenarios covering stopped fallback, persisted rotation, and active recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository MEMBER, so the external-contributor gate does not apply; the captured body additionally reports real planner/Chutes HTTP scenarios covering stopped fallback, persisted rotation, and active recovery.
Evidence reviewed 9 items Current main still needs the fix: The fetched main revision retains an unconditional preparation loop; failed credential resolution appends the failed profile and continues without consulting catalog liveness.
Introduced lifecycle repair: The verified merge-base-to-head delta passes the existing owner’s liveness callback into preparation and closes admission directly in the timeout callback. The callback is removed before plugin catalog parameters are returned, preserving the plugin API.
Refresh persistence remains independently owned: The existing OAuth manager awaits refresh completion and persists the rotated credential through its locked store owner. The patch does not cancel or replace this flow; profile fallback inside credential resolution is already disabled for catalog preparation.
Findings None None.
Security None None.

How this fits together

Model discovery prepares credentials from configured accounts before asking provider plugins for available models. Its timeout controls which preparation and catalog results may contribute to the published inventory.

flowchart TD
  A[Configured accounts] --> B[Catalog timeout owner]
  B --> C{Discovery still active?}
  C -->|Yes| D[Prepare selected credential]
  D -->|Failed candidate| C
  D --> E[Persist completed token rotation]
  E --> F{Discovery still active?}
  F -->|Yes| G[Provider catalog and model inventory]
  C -->|No| H[Stop further preparation]
  F -->|No| H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +8, Tests +88. Total +96 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 10 2 +8
Tests 1 129 41 +88
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 139 43 +96

Review metrics

Metric Value Why it matters
Timeout controls 3 scenarios: late failure, late success, active fallback The coverage distinguishes stopping new work from preserving token rotation and normal fallback.

Technical review

Best possible solution:

Keep deadline admission with the catalog owner and token persistence with the existing refresh owner, preserving fallback while discovery remains active.

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

Yes, from source: let account A’s refresh fail after the catalog timeout while account B remains eligible; main’s unconditional loop then attempts B. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Yes. Reusing the existing lifecycle flag closes the preparation gap without adding settings, changing plugin contracts, or interrupting rotation persistence.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs bounded background credential work after model discovery times out, without evidence of an urgent user-facing outage.
  • 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 author is a repository MEMBER, so the external-contributor gate does not apply; the captured body additionally reports real planner/Chutes HTTP scenarios covering stopped fallback, persisted rotation, and active recovery.

Evidence

What I checked:

  • Current main still needs the fix: The fetched main revision retains an unconditional preparation loop; failed credential resolution appends the failed profile and continues without consulting catalog liveness. (src/agents/models-config.providers.discovery-auth.runtime.ts:118, 208aab3aa6f0)
  • Introduced lifecycle repair: The verified merge-base-to-head delta passes the existing owner’s liveness callback into preparation and closes admission directly in the timeout callback. The callback is removed before plugin catalog parameters are returned, preserving the plugin API. (src/agents/models-config.providers.catalog-context.ts:41, 4af27929a071)
  • Refresh persistence remains independently owned: The existing OAuth manager awaits refresh completion and persists the rotated credential through its locked store owner. The patch does not cancel or replace this flow; profile fallback inside credential resolution is already disabled for catalog preparation. (src/agents/auth-profiles/oauth-manager.ts:675, 4af27929a071)
  • Regression coverage: The complete test file covers late refresh failure, late refresh success with persisted rotation, and active fallback using the second account’s refreshed token. It joins preparation before checking late requests, outcomes, and persisted credentials. (test/openai-model-discovery-auth-order.test.ts:357, 4af27929a071)
  • Updated proof and review continuity: The captured body at sourceRevision e928f4ab9ebf8fc3f9c0921231c5ea8b5af9bd7ef3d4f29e521aa9810a9c4a6b identifies the reviewed head, reports 63 passing affected tests and completed changed-path validation, and describes ensureOpenClawModelsJson exercising the real Chutes plugin and refresh owner against controlled HTTP responses. Its three recorded outcomes cover late failure, persisted late success, and successful active fallback. This supersedes the previous review’s pending-validation statement; no previous code findings were retained. These are supplied validation reports, not reviewer-executed runs. (4af27929a071)
  • Related work has distinct scope: The supplied GitHub metadata verifies fix: keep OpenAI model discovery on configured auth profile #137120 as merged account-selection work. The open fix: preserve models when OAuth preparation fails #139951 addresses inventory retention after all OAuth candidates fail and explicitly leaves timeout admission to this PR; neither supersedes this repair.

Likely related people:

  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • openclaw/openclaw-secops: 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 (2 earlier review cycles)
  • reviewed 2026-09-06T08:14:56.539Z sha 59c733f :: needs changes before merge. :: none
  • reviewed 2026-09-06T08:25:49.911Z sha 4af2792 :: needs changes before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 6, 2026
@shakkernerd shakkernerd self-assigned this Sep 6, 2026
@shakkernerd
shakkernerd merged commit 426f7bd into main Sep 6, 2026
185 checks passed
@shakkernerd
shakkernerd deleted the fix/catalog-auth-timeout branch September 6, 2026 09:16
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: catalog discovery no longer starts another OAuth refresh after its timeout.

steipete added a commit to lucascmg-vx/openclaw that referenced this pull request Sep 6, 2026
Merge verified main c5a7231, including
openclaw#139997 on-demand SDK aliases and openclaw#139924 catalog timeout ownership.
Preserve the Bedrock runtime, fixture and LLM export bytes. Documentation
retains the existing scheduler guidance alongside disjoint main updates.

The prior Bedrock HTTP and build checks passed; shared ACP cleanup and
literal OAuth discovery failures require these canonical owner fixes.
A fresh exact-head CI run follows this reviewed integration.

Co-authored-by: Lucas Cardoso <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 7, 2026
…139924)

Stop OAuth fallback after catalog discovery times out while allowing an in-flight credential refresh to finish safely.

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

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant