Skip to content

fix(auth): clean refresh contention diagnostics - #83383

Closed
vincentkoc wants to merge 1 commit into
mainfrom
impact/agents-applypatch-auth-followup
Closed

vincentkoc wants to merge 1 commit into
mainfrom
impact/agents-applypatch-auth-followup

Conversation

@vincentkoc

@vincentkoc vincentkoc commented May 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Keep OAuth refresh_contention diagnostics deterministic by avoiding nested file-lock cause flattening in user-facing refresh failures.
  • Preserve programmatic code / lockPath on OAuthManagerRefreshError while redacting lock paths from messages and JSON-facing diagnostics, including structured non-Error causes.
  • Add regression coverage for manager-level redaction and resolver-level single-message surfacing.

Related PRs and Issues

Verification

Real behavior proof

Behavior addressed: OAuth refresh contention failures no longer expose file-lock paths in user-facing refresh diagnostics, and the contention text is surfaced once instead of duplicated through cause-chain flattening.

Real environment tested: Fresh OpenClaw gwt branch off current origin/main, with focused local auth-profile tests, focused lint, branch re-review, and Blacksmith Testbox changed-gate proof on the pushed PR head.

Exact steps or command run after this patch: node scripts/run-vitest.mjs src/agents/auth-profiles/oauth-manager.test.ts src/agents/auth-profiles/oauth.test.ts; node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/agents/auth-profiles/oauth-manager.ts; .agents/skills/autoreview/scripts/autoreview --mode branch; node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --blacksmith-org openclaw --blacksmith-workflow .github/workflows/ci-check-testbox.yml --blacksmith-job check --blacksmith-ref main --idle-timeout 90m --ttl 240m --timing-json -- CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_TEST_PROJECTS_PARALLEL=6 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 pnpm check:changed.

Evidence after fix: Regression tests assert refresh_contention messages do not contain the synthetic lock path or file lock timeout, including structured non-Error causes, and that both OAuth token refresh failed and OAuth refresh failed (refresh_contention) appear only once. Autoreview found no actionable correctness issues, and Testbox-through-Crabbox passed pnpm check:changed with exit 0.

Observed result after fix: Focused auth-profile tests passed, focused oxlint passed, branch review passed, and Testbox changed-gate passed on the pushed head d754e783bc69e4c50dd57d79bd9db31519540ea5.

What was not tested: No live OAuth provider refresh was forced; this is a deterministic diagnostic/redaction hardening path covered by mocked contention errors and manager-level error construction.

@vincentkoc vincentkoc self-assigned this May 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels May 18, 2026
@clawsweeper

clawsweeper Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed July 1, 2026, 12:51 AM ET / 04:51 UTC.

Summary
The PR changes OAuth refresh error formatting and tests to redact refresh_contention lock-cause details, avoid duplicate refresh-failure text, and adds one changelog line.

PR surface: Source +38, Tests +152, Docs +1. Total +191 across 5 files.

Reproducibility: yes. Source inspection shows current main still flattens refresh_contention causes and rewraps the manager message; the PR tests model that path without requiring live OAuth credentials.

Review metrics: none identified.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🐚 platinum hermit
Patch quality: 🦐 gold shrimp
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Rebase over current main and keep OAuthRefreshFailureError provider/reason classification intact.
  • Remove the CHANGELOG.md edit and leave release-note context in the PR body or squash/direct commit message.
  • Rerun focused auth-profile tests and changed-gate proof on the final rebased head.

Risk before merge

  • [P1] The branch is currently conflicting, so the rebase must adapt the diagnostic cleanup to the current OAuthRefreshFailureError object-constructor and provider/reason classification path.
  • [P1] Because the PR changes OAuth refresh error wrapping, a poor rebase could regress auth-provider diagnostics or structured refresh failure classification even if focused tests still pass.
  • [P1] The diff still edits release-owned CHANGELOG.md; that line should be removed before merge and the release-note context kept in the PR body or commit message.

Maintainer options:

  1. Rebase over current auth classification (recommended)
    Adapt the redaction and prefix-stripping changes to the current OAuthRefreshFailureError provider/reason shape, remove the changelog line, and rerun focused auth-profile plus changed-gate proof.
  2. Keep the draft paused
    Leave the maintainer-owned draft open until a maintainer resolves the conflict and refreshes validation on the final branch head.

Next step before merge

  • [P2] The maintainer-labeled draft is conflicting and needs maintainer rebase plus final proof refresh rather than a narrow automated repair.

Security
Cleared: No supply-chain or credential-routing regression was found; the diff is intended to reduce local lock-path exposure and does not change dependencies, workflows, permissions, or secret storage.

Review findings

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:107
Review details

Best possible solution:

Land a rebased auth diagnostic fix that preserves current OAuthRefreshFailureError classification, redacts refresh_contention lock details once, removes the changelog edit, and refreshes final-head auth-profile proof.

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

Yes. Source inspection shows current main still flattens refresh_contention causes and rewraps the manager message; the PR tests model that path without requiring live OAuth credentials.

Is this the best way to solve the issue?

Mostly yes. The manager/resolver diagnostic layer is the right place for this cleanup, but the branch is not the best merge shape until it is rebased over current auth-failure classification and the changelog edit is removed.

Full review comments:

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:107
    Normal PRs should not edit release-owned CHANGELOG.md. Keep this release-note context in the PR body or squash/direct commit message so release generation owns the changelog.
    Confidence: 0.91

Overall correctness: patch is correct
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This is a normal-priority OAuth diagnostic/redaction bug fix with limited blast radius but real auth-provider operator impact.
  • merge-risk: 🚨 auth-provider: The PR changes OAuth refresh error wrapping and must preserve provider/reason classification and auth diagnostics during rebase.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this MEMBER maintainer-labeled draft; the PR body includes focused tests and Testbox output, but no live OAuth refresh was forced.
Evidence reviewed

PR surface:

Source +38, Tests +152, Docs +1. Total +191 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 49 11 +38
Tests 2 157 5 +152
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 207 16 +191

What I checked:

Likely related people:

  • vincentkoc: Auth redaction work in merged PR 82670 and the oauth lifecycle manager history touch the same OAuthManagerRefreshError and resolver surfaces. (role: recent area contributor; confidence: high; commits: 05123db93cf7, 5f2e77a6e1c4, 4a4f52b09730; files: src/agents/auth-profiles/oauth-manager.ts, src/agents/auth-profiles/oauth.ts, src/agents/auth-profiles/oauth-manager.test.ts)
  • RomneyDa: Merged PR 89181 introduced the current OAuthRefreshFailureError provider/reason classification that this branch must preserve while rebasing. (role: recent adjacent owner; confidence: medium; commits: 50b69e16dc0d; files: src/agents/auth-profiles/oauth-refresh-failure.ts, src/agents/auth-profiles/oauth.ts, src/agents/auth-profiles/oauth-manager.ts)
  • visionik: Merged PR 67876 added cross-agent OAuth refresh serialization and the refresh_contention lock surface that this PR hardens diagnostically. (role: introduced related behavior; confidence: medium; commits: 8e79080bef7d; files: src/agents/auth-profiles/oauth.ts, src/agents/auth-profiles/oauth-refresh-lock-errors.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. P2 Normal backlog priority with limited blast radius. impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels May 18, 2026
@vincentkoc
vincentkoc force-pushed the impact/agents-applypatch-auth-followup branch from 5d0497c to d754e78 Compare May 18, 2026 06:47
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. labels May 18, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jun 21, 2026
@steipete

steipete commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The useful fix has landed through #101573 as 46276312d6c0528d316062bf0845d9620fc3e3be, with contributor credit preserved.

That current-main replay keeps the canonical refresh_contention text singular, prevents the nested file-lock path from leaking into the public diagnostic, and preserves the current OAuthRefreshFailureError plus structured code / lockPath contract. Focused Testbox proof passed 3 files / 47 tests, pnpm check:changed, formatter, fresh autoreview, exact-head hosted CI/security/OpenGrep, and the native prepare/merge gates.

I recreated the patch because this branch could not be updated by maintainers (Allow edits by maintainers is disabled) and had drifted across the current OAuth error-classification path. The replay deliberately discarded the stale broad test rewrites and retained the behavior at the current manager/resolver boundary.

Thanks @vincentkoc for finding and working through this diagnostic bug. Enabling Allow edits by maintainers on future contributor PRs lets us refresh the original branch directly instead of recreating it.

@steipete steipete closed this Jul 7, 2026
@shakkernerd
shakkernerd deleted the impact/agents-applypatch-auth-followup branch October 19, 2026 23:21
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 merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

OAuth token refresh race condition causes spurious failovers (refresh_token_reused)

2 participants