fix: 修复聚合供应商切换后的登录与模式误判 - #1813
Open
yanlong832-source wants to merge 2 commits into
Open
Conversation
切换聚合供应商时 auth.json 被清空为 0 字节,导致 Codex 桌面版(以 auth.json 的 OPENAI_API_KEY 作为已登录判据)弹出登录界面,纯 API Key 用户无法进入。 聚合模式的请求认证由本地协议代理(127.0.0.1:57321)的 internal token 完成,真实上游 Key 只保存在 settings.json,因此 auth.json 内容不影响请求。切换时保留已有 Key,缺失时写入占位 Key 即可绕过登录界面。 Official/MixedApi 模式行为不变(仍删除 OPENAI_API_KEY),新增三个单元测试覆盖聚合保留、聚合占位、官方删除三条路径。
统一管理器聚合写入与供应商切换路径,始终基于实时 auth.json 保留认证字段并补齐占位 Key。回填实时配置时保持 Aggregate 模式,避免被占位 Key 误判为 PureApi。 新增核心与管理器回归测试,覆盖旧快照忽略、认证字段保留、本地代理配置和模式回填。
yanlong832-source
force-pushed
the
fix/aggregate-auth-placeholder
branch
from
August 10, 2026 05:28
2ac3bef to
c3655d8
Compare
Owner
|
补充一个 P1 数据完整性问题: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
纯 API Key 用户切换到聚合供应商后,
auth.json中的OPENAI_API_KEY会被删除或被旧路径整体重写。Codex 桌面版因此误判为未登录并显示登录页面。此外,管理工具从实时配置回填时会把聚合模式写入的占位 Key 识别为普通 API Key,进而将
RelayMode::Aggregate错误改成PureApi,丢失聚合轮转语义。修复内容
auth.json中已有的OPENAI_API_KEY。auth.json中 OAuth 等其他字段,不使用聚合 profile 的旧认证快照覆盖实时状态。RelayMode::Aggregate。聚合成员的真实 API Key 仍只来自各成员供应商配置;占位值不参与上游请求认证。聚合请求继续通过本地代理
127.0.0.1:57321和内部 tokencodex-plus-aggregate转发。回归覆盖
新增单元与集成测试,覆盖:
验证
git diff --check通过。cargo test未完成:离线缓存缺少依赖,联网依赖下载在 120 秒后超时,尚未进入可见测试执行阶段。建议以 CI 结果作为完整 Rust 测试依据。