fix: fallback to provider credentials for usage script tests#1689
fix: fallback to provider credentials for usage script tests#1689Alexlangl wants to merge 5 commits into
Conversation
farion1231
left a comment
There was a problem hiding this comment.
感谢您的贡献,请查看一下有没有以下问题:
第一,新的 fallback helper 没有覆盖 Codex 现有的标准配置结构,也就是 auth.OPENAI_API_KEY 和 config TOML 里的 base_url,这会导致 Codex 在“测试用量脚本”时如果把凭证输入框留空,仍然解析成空字符串,和本 PR “回退到 provider 凭证”的目标不一致;
第二,helper 也丢掉了仓库其他路径已经兼容的 api_key / base_url 别名,因此一部分旧配置或 additive config 依然无法走到 fallback。除此之外,这个 PR 还引入了几处需要在描述里明确说明的行为变化:test_usage_script 现在从“仅使用传入参数”变成“查库后与 provider 配置合并”,凭证优先级也从原先偏向 env.* 变成顶层 apiKey / options.apiKey 优先,同时顶层和 options 里的 baseUrl 现在也会统一去掉尾部 /;这些不一定是问题,但都属于用户可感知的兼容性变化。
另有一个小的实现建议是 test_usage_script 可以直接使用现有的 get_provider_by_id,避免先加载整个 app 下的所有 provider。
感谢review 这次调整:
另外提到的行为变化这部分:
已执行: cargo fmt --manifest-path src-tauri/Cargo.toml
cargo test resolve_usage_credentials --manifest-path src-tauri/Cargo.toml -- --nocapture
cargo test usage --manifest-path src-tauri/Cargo.toml -- --nocapture——— 补充
|
b4788cd to
4cc9ec9
Compare
farion1231
left a comment
There was a problem hiding this comment.
感谢您的跟进,请查看一下是否存在以下问题:
[P1] Codex 的 base_url fallback 解析方式有误,可能选到错误的 TOML 条目,见 usage.rs (line 93) 和 usage.rs (line 154)。
当前实现只是正则抓取 config 里的第一处 base_url,但 Codex 实际上支持通过 model_provider 选择当前激活的 [model_providers.].base_url,仓库里现有逻辑也是按这个约定处理的,见 codex_config.rs (line 143) 和 providerConfigUtils.ts (line 601)。这会导致多 provider 或存在 mcp_servers.*.base_url 时,请求打到错误 host。
|
f46cb7a to
72cf3ac
Compare
|
Closing this for now. I’ve already put a fair amount of time into it, and I don’t want to keep investing more without knowing whether it’s something you still want to move forward. If you’d like to revisit it later, feel free to let me know. |
|
Same message as in #1824 — these changes are welcome and I'd love to get them merged. Happy to help rebase if needed. |
|
Closing this PR and the related ones as I won’t have time to continue working on them. Thanks for the feedback. |
概要
测试用量脚本没有复用 provider 中已有的
apiKey/baseUrl,当这些字段留空时会直接使用空值执行。复现
apiKey/baseUrl结果:不会回退到 provider 配置,而是使用空值
修复
apiKey/baseUrl为空(或仅空白)时,自动使用 provider 配置支持来源:
apiKeybaseUrl/baseURLoptions.apiKeyoptions.baseURLenv.*验证
Related
Fix #1658