fix(inference): demote test-model config-rejection logs to warn! (#3627)
Summary
inference_test_provider_model(the Settings "Test model" button backend) logged every failure aterror!, which the Sentry tracing layer maps to a direct event — bypassing the JSON-RPCreport_error_or_expectedclassifier and flooding Sentry with user-state config-rejections.- Route the
Errlog through the sharedexpected_error_kindclassifier: demote recognized expected/user-state errors towarn!(breadcrumb), keeperror!for genuinely unexpected failures. - The
Errstill propagates to the UI in both branches — no behavior change, only log level / Sentry capture.
Problem
Sentry TAURI-RUST-4M6 — [inference::ops] test_provider_model:error, ~1296 events / 54 users, live on the latest build (0.57.18). Not a pre-fix tail.
The "Test model" diagnostic deliberately probes an arbitrary user-supplied provider/model, so a failure (unknown model, bad key, region/subscription gate) is user-state, not a defect — and it is already surfaced to the user as Err. But the call site logs it at error!, and sentry_tracing_layer (src/core/logging.rs) maps Level::ERROR -> EventFilter::Event, so the macro fires a Sentry event directly, before and independent of the RPC classifier that already recognizes these bodies. Representative payload: provider=ollama:claude-opus-4-8 → ollama API error (404 Not Found): … "type":"not_found_error" ….
Solution
In inference_test_provider_model's final match, split the Err arm on crate::core::observability::expected_error_kind(err):
Some(_)→warn!("… test_provider_model:rejected")(breadcrumb, no Sentry event)None→error!("… test_provider_model:error")(unchanged — unexpected failures still escalate)
Reusing the single-source expected_error_kind (rather than a fresh matcher) means the test op demotes exactly the set the rest of the app already treats as expected — no duplicated phrase list, no drift. Mirrors the existing inference_list_models user-config demotion in the same file.
Submission Checklist
If a section does not apply to this change, mark the item as
N/Awith a one-line reason. Do not delete items.
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
- [x] Diff coverage ≥ 80% — both new branches exercised by added tests; Coverage Gate CI (diff-cover ≥ 80%) passed.
- [x] N/A: Coverage matrix — log-level / observability-only change, no feature row.
- [x] N/A: feature IDs — no matrix rows; Sentry issue referenced under Related instead.
- [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
- [x] N/A: manual smoke — no release-cut surface touched.
- [x] Linked issue closed via
Closes #NNNin the## Relatedsection
Impact
- Desktop only. No runtime/perf/migration/compat impact — changes the log level of a single error path. Failed "Test model" attempts now surface as
warn!breadcrumbs instead oferror!Sentry events; the user-facingErris unchanged. - Security: none. No data path, no swallowed error —
Errstill propagates. - Note: a chat-path failure whose body
expected_error_kinddoes not yet recognize (e.g. some 401 shapes) still escalates aserror!— intentional; widening the classifier is out of scope for this issue.
Related
- Closes: #3627
- Sentry-Issue: TAURI-RUST-4M6
- Follow-up PR(s)/TODOs: none
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
- Key: N/A
- URL: N/A
Commit & Branch
- Branch: fix/3627-test-provider-model-sentry-noise
- Commit SHA: 020198b2e6a2cdf176564f0206c064c860e095f7
Validation Run
- [x] N/A:
pnpm --filter openhuman-app format:check— no frontend change. - [x] N/A:
pnpm typecheck— no frontend change. - [x] Focused tests:
cargo test --lib openhuman::inference::ops— 19 passed, 0 failed. - [x] Rust fmt/check:
cargo fmt --checkclean;cargo checkclean. - [x] N/A: Tauri fmt/check — core lib only, no
app/src-taurichange.
Validation Blocked
command:N/Aerror:N/Aimpact:N/A
Behavior Changes
- Intended behavior change: failed "Test model" config-rejections log at
warn!(breadcrumb) instead oferror!(Sentry event) - User-visible effect: none — the error is still returned to the UI; only Sentry noise is removed
📝 Walkthrough
Walkthrough
The PR reduces Sentry noise by demoting user configuration errors in the test-provider diagnostic from error! to warn! level using the existing expected_error_kind classifier. Implementation changes log routing in inference_test_provider_model, while new unit and end-to-end tests validate the behavior with Ollama 404 config-rejection payloads.
Changes
Test-provider error demotion
| Layer / File(s) | Summary |
|---|---|
Log-level routing via error classification src/openhuman/inference/ops.rs |
inference_test_provider_model's error branch now checks expected_error_kind(err) to emit warn! for expected user/config rejections or error! for unexpected failures, replacing unconditional error! logging. |
Unit and end-to-end tests for error demotion src/openhuman/inference/ops_tests.rs |
Two new tests verify error classification: a unit test asserts Ollama 404 "config-rejection" bodies classify as expected while internal invariants do not; an end-to-end test mocks an Ollama 404 endpoint and validates the error is both returned to the UI and classified as expected. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- tinyhumansai/openhuman#3502: Expands the config-rejection classifier to include 403 subscription-gate errors alongside the 404 not-found errors being demoted here.
Suggested labels
rust-core
Poem
🐰 A config mismatch, a user's test— no need to flood Sentry with the rest! We classify, demote, and log just right, expect the blunder, warn in sight. ✨
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly summarizes the main change: demoting test-model config-rejection logs from error to warn level, which directly addresses the PR's primary objective. |
| Linked Issues check | ✅ Passed | The code changes fully implement the requirements from issue #3627: routing Err through expected_error_kind to demote user-config failures to warn! while preserving error propagation to UI. |
| Out of Scope Changes check | ✅ Passed | All changes are directly scoped to addressing issue #3627: error handling logic in inference_test_provider_model and corresponding tests for the expected_error_kind classification. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
✏️ 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.
Code changes look correct per my analysis in #3627. This is ready for a human review — the logic routes user-config errors to warn! and keeps error! for unexpected failures. @maintainers can someone take a look?
Superseded by #3676 (merged 2026-06-16), which demotes the same inference_test_provider_model expected/user-state failures via expected_test_provider_model_error_kind → observability::expected_error_kind. Identical classifier and behavior, so this PR adds no further coverage for TAURI-RUST-4M6. Closing as duplicate; the bug is fixed on main.