Skip to content

fix(openai): recover OAuth account tests after early token rejection - #8856

Open
yongman wants to merge 1 commit into
Wei-Shaw:mainfrom
yongman:fix/DAT-294-openai-oauth-test-recovery
Open

yongman wants to merge 1 commit into
Wei-Shaw:mainfrom
yongman:fix/DAT-294-openai-oauth-test-recovery

Conversation

@yongman

@yongman yongman commented Nov 16, 2026

Copy link
Copy Markdown

An OpenAI OAuth test that receives an early 401 currently disables the account, removing it from background refresh. Scheduled-test auto-recovery then cannot succeed without manual intervention. This change gives account probes and HTTP forwarding one guarded refresh-and-retry opportunity.

  • Reuse OAuthRefreshAPI locks and durable rereads. Force refresh only for the rejected token/version; reuse a concurrent winner, bound distributed-lock waiting, and fail closed if the recovery lock is unavailable.
  • Persist rotated credentials with a compare-and-set and atomic scheduler invalidation. Invalidate the token cache at the persistence boundary, and condition permanent-error updates on the attempted credentials and state.
  • Keep refreshable probe failures eligible for future refresh. Legacy test authentication errors can refresh while still disabled; only a successful test with existing auto-recovery enabled restores scheduling. Explicit revocation or an invalid refresh token requires reauthorization.
  • Retry the same probe/HTTP payload once. API keys, setup tokens, PATs, Agent Identity, scope errors, and administratively disabled accounts retain their credential-specific handling.

Fixes #8855. Related to #5542, #7826, and #8034. The rejected-token identity guard follows the approach proposed in #7826; this PR independently extends recovery to the account-test lifecycle and guards persistence/state changes. It targets current main (ef2920300); v0.2.21 (10ba8f9b4) exhibits the reported behavior and has not been changed by this PR.

Validation (Go 1.27.4, synthetic credentials and local upstreams):

  • Account-test/provider regressions, including early rejection, legacy error recovery, terminal failures, second rejection, cancellation, cache invalidation, and concurrent rotation winners.
  • Race check for the recovery tests.
  • PostgreSQL/Redis repository integration tests for credential/state comparisons and atomic scheduler invalidation, including the existing Grok persistence regressions.
  • Service/repository unit suites and golangci-lint 2.14.0.

Scope: account probes (text/compact/image transport) and Responses HTTP forwarding/passthrough. WebSocket recovery remains outside this PR and is covered by the related upstream proposal #8034. No schema/configuration migration or production deployment is included. The reason for upstream early invalidation remains unknown.

AI-assisted implementation and validation.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@yongman

yongman commented Nov 16, 2026 •

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@yongman

yongman commented Nov 17, 2026

Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Nov 17, 2026
riofutab added a commit to riofutab/sub2api that referenced this pull request Nov 17, 2026
- 带入上游 11-16 已合的 55 个 PR,同步基准更新为 9cd1a1e;用量汇总改为非阻塞建表(Wei-Shaw#8693),被动用量换窗清理与 Fable 限额恢复采用上游实现(Wei-Shaw#8723 Wei-Shaw#8779)。
- Codex 独立上下文改用上游 Wei-Shaw#8769 的 user 文本归一化,撤回 fork 的 Wei-Shaw#8680 并补回 proposed_plan、guardian、cloud_threads 等类型;Gemini 思考等级改用 Wei-Shaw#8673,撤回 fork 的 Wei-Shaw#8619。
- 合入 24 个开放 PR,Wei-Shaw#8781 与 Wei-Shaw#8705 部分合入;Wei-Shaw#8856、Wei-Shaw#8858 与已有实现重复,未合入。
- 修复转义的 1h TTL 被快速路径漏判,并按 fork 的构造参数与模型目录调整上游测试。
- 后端全量 unit、golangci-lint、前端 vitest、迁移空库回放与 CI 集成测试通过;go.sum 未整理。
xiaoguai1818 pushed a commit to xiaoguai1818/sub2api that referenced this pull request Nov 21, 2026
Restore Antigravity Responses custom-tool roundtrips and correct Embeddings platform scheduling. Harden OAuth probe fencing, request-scoped Gemini 403 behavior, OpenAI stream failover and WebSocket current-turn safety.

Preserve Claude/GPT-6.2/Grok protocol details and model observations; correct Fable/Kimi quota refreshes and user-vs-account cost reporting. Bound scheduler fallback, request memory retention and shutdown/stream lifecycles without unapproved pricing or schema changes.

Local checks: complete Go unit packages, PostgreSQL 18.1/Redis 8.4 repository and audit integration, focused -race, frontend typecheck/lint/1858 Vitest/build, backend lint 0 issues and embedded server build. Remote CI/Security Scan remain pending.

Upstream references: Wei-Shaw/sub2api Wei-Shaw#8833 Wei-Shaw#8875 Wei-Shaw#8856 Wei-Shaw#8730 Wei-Shaw#8990 Wei-Shaw#8806 Wei-Shaw#8832 Wei-Shaw#8809 Wei-Shaw#8164 Wei-Shaw#8804 Wei-Shaw#8773 Wei-Shaw#8309.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scheduled OpenAI OAuth tests can strand refreshable accounts after an early 401

1 participant