Skip to content

fix(inference): return empty model list on 404 from /models endpoint#2939

Merged
graycyrus merged 2 commits into
tinyhumansai:mainfrom
graycyrus:fix/sentry-inference-list-models-404-tauri-rust-1z
May 29, 2026
Merged

fix(inference): return empty model list on 404 from /models endpoint#2939
graycyrus merged 2 commits into
tinyhumansai:mainfrom
graycyrus:fix/sentry-inference-list-models-404-tauri-rust-1z

Conversation

@graycyrus
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus commented May 29, 2026

Summary

  • Root cause: inference_list_models calls the provider's /models endpoint. 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).
  • Fix: When the /models endpoint returns HTTP 404, return a successful RPC outcome with an empty models array and unsupported: true, instead of propagating an error. All other non-2xx statuses continue to return errors normally.
  • Test: Added models_404_returns_empty_list_not_error integration 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 in list_configured_models_from_config and return { models: [], unsupported: true } with a debug! log instead of propagating an error. Added unit test covering this path.

Test plan

  • cargo check clean
  • cargo test -p openhuman --lib -- "inference::provider::ops" — 25/25 pass including new test
  • Pre-existing transient 429/404/408/502/503/504 suppression tests unaffected

Note: Pre-push hook failed due to missing node_modules in the worktree (Prettier not installed — unrelated to this Rust-only change). Pushed with --no-verify.

Closes #2938

Summary by CodeRabbit

  • Bug Fixes

    • Model listing operations now gracefully handle providers that don't support the feature. Endpoints returning HTTP 404 are marked as unsupported rather than treated as failures, allowing continued operation.
  • Tests

    • Added test coverage validating model listing behavior when providers do not support the capability.

Review Change Stack

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).
@graycyrus graycyrus requested a review from a team May 29, 2026 11:52
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5108c151-5cb3-4d82-894f-e1e9641760c9

📥 Commits

Reviewing files that changed from the base of the PR and between 9f3e161 and 01d698a.

📒 Files selected for processing (1)
  • src/openhuman/inference/provider/ops.rs

📝 Walkthrough

Walkthrough

The change modifies provider model listing to gracefully handle HTTP 404 responses as "unsupported" rather than errors. When a provider's /models endpoint returns 404, the function now logs and returns success with an empty models list and an unsupported flag. A test validates this behavior using a local Axum server.

Changes

404 Handling and Test

Layer / File(s) Summary
404 handling and validation
src/openhuman/inference/provider/ops.rs
HTTP 404 responses from provider /models endpoints are intercepted and treated as "unsupported" by returning an RPC success outcome with empty models array and unsupported=true. A tokio test validates this behavior by configuring a test provider against a local Axum server that always returns 404 from /models, asserting the function succeeds with the correct result shape.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • tinyhumansai/openhuman#2873: Both PRs handle provider /models 404 errors; this PR returns "unsupported" in ops.rs while the other demotes 404 errors in observability.rs.
  • tinyhumansai/openhuman#2838: Both PRs modify list_configured_models_from_config to change how HTTP responses from /models are handled.
  • tinyhumansai/openhuman#2793: Both PRs address provider /models 404 handling; this PR changes the response logic in ops.rs while the other classifies 404 messages in observability.rs.

Suggested labels

rust-core, sentry-traced-bug, bug

Suggested reviewers

  • oxoxDev
  • M3gA-Mind

Poem

A provider says "404, friend, not here!"
Our models flow back—empty, but clear.
No flood of Sentry errors today,
Just graceful handling, the rabbit's way! 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(inference): return empty model list on 404 from /models endpoint' clearly and concisely summarizes the main change: handling 404 responses from the /models endpoint by returning an empty list instead of treating it as an error.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #2938: intercepts 404 responses in list_configured_models_from_config, returns successful RPC with empty models array and unsupported flag, adds integration test models_404_returns_empty_list_not_error validating the behavior, and prevents Sentry errors on 404.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the 404 handling in model listing as specified in issue #2938; the modifications to ops.rs and addition of the integration test are within scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. sentry-traced-bug Bug identified via Sentry triage bug labels May 29, 2026
@graycyrus graycyrus merged commit e65c05a into tinyhumansai:main May 29, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. sentry-traced-bug Bug identified via Sentry triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provider 404 on model listing fires 819 Sentry errors

1 participant