CodePilot icon indicating copy to clipboard operation
CodePilot copied to clipboard

fix(openai/codex): 优化 OAuth 失败可观测性与用户提示

Open KevinYoung-Kw opened this issue 7 months ago • 4 comments

变更说明

  • 持久化最近一次 OpenAI OAuth 失败原因,并通过 /api/openai-oauth/status 返回给前端
  • 解析嵌套错误结构,避免 403 - [object Object] 这类不可读报错
  • 在设置页对常见 Codex/OpenAI OAuth 失败给出可操作提示(例如地区不支持、state 过期)

背景

部分用户在 OAuth token exchange 阶段失败时,只能在回调页看到不直观错误,难以判断下一步操作。本 PR 将错误原因同步到应用内,提高可诊断性和可用性。

验证

  • npm run -s typecheck

Fixes #464

KevinYoung-Kw avatar Apr 16 '26 11:04 KevinYoung-Kw

@KevinYoung-Kw is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Apr 16 '26 11:04 vercel[bot]

补充复现结果(网络代理场景):

  • 规则代理:✕
  • 全局代理:✕
  • 全局代理 + 增强模式/TUN 模式:✓

结论:当前 OpenAI OAuth token exchange 对网络链路质量较敏感,开启全局代理并使用增强/TUN 后可稳定完成授权。

KevinYoung-Kw avatar Apr 16 '26 11:04 KevinYoung-Kw

补充同步:这次已把分支基于最新 main 对齐后回推到原 PR 分支。保留了 OAuth 失败可观测性优化(例如 Invalid state、403/地区限制等错误提示更可读),并完成了本地相关用例回归。

KevinYoung-Kw avatar Apr 20 '26 03:04 KevinYoung-Kw

本地这边已经把这条线重新对齐到最新主线基线后推上来了

KevinYoung-Kw avatar Apr 23 '26 07:04 KevinYoung-Kw

已用最新 main(v0.67.1)重开:#673。

这条旧分支不再跟。#673 保留嵌套 error 解析、lastError / oauthError、地区和 state 过期提示,并改成真实 i18n(不再用 t('nav.chats') === '对话')。不引入并发 pendingOAuthByState。

KevinYoung-Kw avatar Aug 20 '26 01:08 KevinYoung-Kw

Superseded by https://github.com/op7418/CodePilot/pull/673

KevinYoung-Kw avatar Aug 20 '26 01:08 KevinYoung-Kw