fix(inference): return empty model list on 404 from /models endpoint#2939
Conversation
Many OpenAI-compatible providers (DeepSeek, Kimi, Moonshot, custom proxies) do not implement the /models discovery endpoint and return 404. The previous code treated this as an error, which propagated up through `inference_list_models` and fired a Sentry event for each call. Fix: when the /models endpoint returns 404, return an empty model list with `unsupported: true` instead of erroring. Providers without model listing are expected — not all providers expose /models. Closes tinyhumansai#2938, resolves Sentry TAURI-RUST-1Z (819 events).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change modifies provider model listing to gracefully handle HTTP 404 responses as "unsupported" rather than errors. When a provider's Changes404 Handling and Test
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
inference_list_modelscalls the provider's/modelsendpoint. Many OpenAI-compatible providers (DeepSeek, Kimi, Moonshot, custom proxies) do not implement this endpoint and return 404. The previous code treated any non-2xx response as an error, causing a Sentry event for each call — 819 events across multiple releases (Sentry issue TAURI-RUST-1Z)./modelsendpoint returns HTTP 404, return a successful RPC outcome with an emptymodelsarray andunsupported: true, instead of propagating an error. All other non-2xx statuses continue to return errors normally.models_404_returns_empty_list_not_errorintegration test that spins up a minimal axum server returning 404 on/models, then asserts the empty-list outcome.Changes
src/openhuman/inference/provider/ops.rs: intercept 404 inlist_configured_models_from_configand return{ models: [], unsupported: true }with adebug!log instead of propagating an error. Added unit test covering this path.Test plan
cargo checkcleancargo test -p openhuman --lib -- "inference::provider::ops"— 25/25 pass including new testCloses #2938
Summary by CodeRabbit
Bug Fixes
Tests