fix: route embedding emitters through expected-error reporting
Summary
- Routed embedding error emission through
report_error_or_expectedat the three direct-emit sites called out in kickoff. - Added focused classifier-state tests for Ollama/OpenAI embedding wire-shapes to lock current expected vs unexpected behavior.
- Kept scope strictly in embeddings modules; no
src/core/observability.rschanges.
Problem
ollama.rsandopenai.rswere usingreport_error(...)directly, bypassing expected-error classification and creating avoidable Sentry noise.- We needed the Sentry-only routing swap while avoiding ongoing merge traffic in
observability.rslanes.
Solution
- Swapped
report_error(message.as_str(), ...)toreport_error_or_expected(&message, ...)at:src/openhuman/embeddings/ollama.rs(transport and non-2xx paths)src/openhuman/embeddings/openai.rs(non-2xx path)
- Added test coverage in embeddings tests to capture current classifier state for MA/KM/GP/GX-style wire strings and a guard for genuine parse/OpenAI key errors remaining unexpected.
- Left classifier-arm additions to follow-up lanes touching
observability.rs.
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
- [x] N/A: Diff coverage β₯ 80% is enforced by CI for this branch/repo workflow
- [x] N/A: No coverage-matrix feature-row add/remove/rename in this change
- [x] N/A: No affected feature IDs were added/removed for matrix mapping in this lane
- [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
- [x] N/A: No release-cut manual-smoke surface touched
- [x] Linked issue closed via
Closes #NNNin the## Relatedsection
Impact
- Runtime impact is limited to embedding error reporting behavior (classifier-routed vs direct emit).
- No migration, schema, or compatibility changes.
- MA/KM/GX classifier-arm follow-up remains in the observability lanes; this PR intentionally avoids those file conflicts.
Related
- Closes: Closes OPENHUMAN-TAURI-MA Closes OPENHUMAN-TAURI-KM Closes OPENHUMAN-TAURI-GP Closes OPENHUMAN-TAURI-GX
- Follow-up PR(s)/TODOs: Classifier-arm additions for MA/KM/GX wire shapes after observability lane merges (#2063 / #2188 family).
AI Authored PR Metadata (required for Codex/Linear PRs)
Keep this section for AI-authored PRs. For human-only PRs, mark each field
N/A.
Linear Issue
- Key: N/A
- URL: N/A
Commit & Branch
- Branch:
fix/sentry-ollama-embed-emitter - Commit SHA:
1a22b1ddc61d3bb6fdf7727ab5c4e567ab225ec5
Validation Run
- [x] N/A:
pnpm --filter openhuman-app format:check(Rust-only lane) - [x] N/A:
pnpm typecheck(Rust-only lane) - [x] Focused tests:
CARGO_TARGET_DIR=target_codex cargo test --lib openhuman::embeddings::ollama::tests:: -- --test-threads=1;CARGO_TARGET_DIR=target_codex cargo test --lib openhuman::embeddings::openai::tests::openai_embedding_api_error_stays_unexpected -- --exact - [x] Rust fmt/check (if changed):
cargo fmt;CARGO_TARGET_DIR=target_codex cargo check - [x] N/A: Tauri fmt/check (if changed)
Validation Blocked
command:CARGO_TARGET_DIR=target_codex cargo clippy --all-targets -- -D warningserror:Fails on pre-existing repository-wide warnings/lints outside this PR scopeimpact:No local all-target clippy clean signal for this lane; relied on focused tests + CI
Behavior Changes
- Intended behavior change: Embedding provider errors now flow through expected-error classifier routing.
- User-visible effect: Fewer noisy Sentry captures for expected embedding conditions; runtime behavior unchanged.
Parity Contract
- Legacy behavior preserved: Embedding request/response/error handling semantics preserved.
- Guard/fallback/dispatch parity checks: Only observability reporting API changed at emit sites.
Duplicate / Superseded PR Handling
- Duplicate PR(s): N/A
- Canonical PR: This PR
- Resolution (closed/superseded/updated): N/A
Summary by CodeRabbit
-
Bug Fixes
- Improved error tracking and classification for embedding API failures to better distinguish between expected and unexpected errors.
-
Tests
- Added test coverage to verify error classification behavior for embedding services.
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: 9e7a414a-3e20-49f7-8fe9-d965d6faf86e
π₯ Commits
Reviewing files that changed from the base of the PR and between 3aa2984e3f823fc16b3a0ec8a5125a878acd309b and 1a22b1ddc61d3bb6fdf7727ab5c4e567ab225ec5.
π Files selected for processing (4)
src/openhuman/embeddings/ollama.rssrc/openhuman/embeddings/ollama_tests.rssrc/openhuman/embeddings/openai.rssrc/openhuman/embeddings/openai_tests.rs
π Walkthrough
Walkthrough
Both Ollama and OpenAI embedding providers' error reporting paths are updated to use report_error_or_expected instead of report_error, enabling classification of expected vs. unexpected errors. Unit tests validate that various error message patterns are classified correctly, ensuring expected errors skip incident reporting while authentic issues remain visible.
Changes
Embedding Error Reporting Classification
| Layer / File(s) | Summary |
|---|---|
Ollama embedding error reporting refactor src/openhuman/embeddings/ollama.rs |
Transport-failure (.send().await) and non-2xx HTTP response error paths switch from report_error to report_error_or_expected, preserving error messages and observability context. |
Ollama error classification test suite src/openhuman/embeddings/ollama_tests.rs |
New #[test] functions validate expected_error_kind classifications for MA/KM/GX/GP "wire shape" messages (remaining unclassified or routing through classification) and Ollama parse errors (unclassified). |
OpenAI embedding error reporting refactor src/openhuman/embeddings/openai.rs |
Non-2xx embedding response error path switches from report_error(message.as_str(), ...) to report_error_or_expected(&message, ...) with metadata and bail behavior unchanged. |
OpenAI error classification test src/openhuman/embeddings/openai_tests.rs |
New test openai_embedding_api_error_stays_unexpected verifies OpenAI 401 authentication errors return None (unexpected), ensuring API credential failures reach Sentry unfiltered. |
Estimated code review effort
π― 2 (Simple) | β±οΈ ~12 minutes
Possibly related PRs
- tinyhumansai/openhuman#1795: Introduces the foundational
ExpectedErrorKindclassification logic andreport_error_or_expectedfunction that this PR applies to embedding error paths. - tinyhumansai/openhuman#1798: Extends error classification to other transient leak paths (channels/composio) using the same
report_error_or_expectedobservability mechanism. - tinyhumansai/openhuman#1719: Expands the
expected_error_kindclassifier to treat session-expired 401 errors as expected, complementing the embedding error filtering introduced here.
Suggested labels
working
Suggested reviewers
- senamakel
- graycyrus
π° Embedding errors now wear a sorting hat,
Expected ones skip the Sentry chat,
Ollama and OpenAI aligned,
Error classification by design! β¨
π₯ 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 clearly and accurately summarizes the main change: replacing direct error reporting calls with expected-error routing in embedding modules. |
| Docstring Coverage | β Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| Linked Issues check | β Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | β Passed | Check skipped because no linked issues were found for this pull request. |
βοΈ 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.