fix(model-catalog): keep versioned base URL when fetching model list (#1349)#1363
Open
LeoLin990405 wants to merge 1 commit into
Open
fix(model-catalog): keep versioned base URL when fetching model list (#1349)#1363LeoLin990405 wants to merge 1 commit into
LeoLin990405 wants to merge 1 commit into
Conversation
models_endpoint() only special-cased base URLs ending in /v1, so any provider whose base URL carries a different version segment (e.g. Volcano Engine ARK's .../api/coding/v3) got /v1/models appended, producing .../api/coding/v3/v1/models and a 404 on 'fetch models from upstream' and provider doctor, even though chat completions worked fine. Reuse the protocol proxy's has_version_suffix() so the client-side model list fetch matches the version handling the proxy already applies. /v1 and version-less bases keep their current behavior. Adds a regression test covering a versioned (.../api/coding/v3) base URL. Fixes BigPizzaV3#1349
Author
|
✅ Update: Rust toolchain now available — verified locally. The new regression test passes and the crate builds clean (only pre-existing dead-code warnings, none from this change). Ready for review. / 已在本机跑通 |
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.
问题 / Problem
配置火山引擎 ARK 供应商后,「诊断供应商」失败、「从上游获取模型」报 HTTP 404,但进入 Codex 聊天一切正常(issue #1349)。
根因在
model_catalog.rs::models_endpoint():它只把结尾是/v1的 base URL 特判为<base>/models,其它一律拼<base>/v1/models。ARK 的 base 形如.../api/coding/v3(仓库自己的测试tests/relay_config.rs也用这个值),于是被拼成:有意思的是,
protocol_proxy.rs早就用has_version_suffix()正确处理了任意/vN版本段(/v1/v1还会被折叠),所以实际聊天请求走 proxy 正常——只有客户端这条「拉模型列表」的路径用了这个过时的、只认/v1的实现,两边逻辑分叉才导致 404。models_endpoint()only special-cased base URLs ending in/v1, appending/v1/modelsto everything else. Providers with a different version segment (Volcano Engine ARK:.../api/coding/v3) got.../api/coding/v3/v1/models→ 404 on "fetch models from upstream" and provider doctor, even though chat completions worked.protocol_proxy.rsalready handles arbitrary/vNsuffixes viahas_version_suffix(); only this client-side path diverged.改动 / Change
protocol_proxy::has_version_suffix由私有提升为pub(crate);model_catalog::models_endpoint复用它 —— base 已带版本段(/v1、/v3、/api/coding/v3…)时直接追加/models,否则维持追加/v1/models。/v1与无版本 base 的现有行为完全不变,只修好了非/v1版本段被重复拼/v1的 bug。model_catalog_appends_models_to_versioned_base_url:用.../api/coding/v3base,断言实际请求路径是/api/coding/v3/models(而非/api/coding/v3/v1/models)。测试骨架沿用现有spawn_models_servermock。Reuse the proxy's already-tested
has_version_suffix()so the two code paths agree./v1and version-less bases are unchanged.3 文件
+52/-2。测试 / Testing
cargo test。改动已逐行人工核对(&String→&strderef 强转、inline format 捕获、无新 import),且复用的has_server_suffix已被 proxy 侧覆盖使用。烦请维护者在合并前跑一次cargo test -p codex-plus-core --test model_catalog;如需我在有工具链的机器上补跑并回帖也可以。cargo testlocally (no Rust toolchain in the submitting environment). The change is small and manually reviewed; please runcargo test -p codex-plus-core --test model_catalogbefore merging, or let me know and I'll run it on a machine with the toolchain and report back.