fix(observability): suppress embeddings API-key 401 Sentry noise (CORE-RUST-EK)#2934
Conversation
Adds `is_embeddings_api_key_401_event` — a tag-based `before_send` filter that drops Sentry events matching `domain=embeddings` + `failure=non_2xx` + `status=401`. Sentry issue CORE-RUST-EK (827 events, domain=embeddings, operation=openai_embed, model=text-embedding-3-large): every cloud embedding call that returns HTTP 401 (stale or invalid API key) fires a Sentry error event via `report_error_or_expected` in `embeddings::openai::embed`. The primary string-based classifier (`is_session_expired_message`) already suppresses the OpenHuman-backend "Invalid token" body shape (TAURI-RUST-4K5), but third-party provider 401 bodies (OpenAI `invalid_api_key` JSON envelope) fall through to Sentry as errors. The fix mirrors PR tinyhumansai#2915 (VOYAGE_API_KEY-missing) and PR tinyhumansai#2924 (billing 401) by adding a defense-in-depth `before_send` filter scoped to the embeddings domain so provider-chat and backend-API 401s remain subject to their own classifiers. Four new unit tests cover: canonical CORE-RUST-EK wire shape, non-401 embedding statuses pass through, non-embeddings domains pass through, and missing-tag guard.
|
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 (2)
📝 WalkthroughWalkthroughThis PR adds a new Sentry ChangesEmbeddings API-key 401 Sentry event suppression
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
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
Closes #2933
Sentry issue CORE-RUST-EK (~827 events,
domain=embeddings,operation=openai_embed,model=text-embedding-3-large): every cloud embedding call returning HTTP 401 (stale or invalid API key) fires a Sentry error viareport_error_or_expectedinembeddings::openai::embed.is_session_expired_message) already suppresses the OpenHuman-backend "Invalid token" body (TAURI-RUST-4K5 —Embedding API error (401 Unauthorized): {"error":"Invalid token"}).{"error":{"code":"invalid_api_key",...}}) fall through that classifier and reach Sentry as errors — those are the CORE-RUST-EK events.Fix: adds
is_embeddings_api_key_401_event— a tag-basedbefore_sendfilter matchingdomain=embeddings+failure=non_2xx+status=401. Wired insrc/main.rsimmediately after the budget-400 filter, following the same pattern as PR #2915 (VOYAGE_API_KEY) and PR #2924 (billing 401).The filter is domain-scoped so provider-chat, backend-API, and RPC 401s remain subject to their own classifiers. The existing
is_session_expired_messagepath is unchanged — TAURI-RUST-4K5 continues to be demoted at the call site before it ever reachesbefore_send.Test plan
is_embeddings_api_key_401_event— 4 new unit tests: canonical CORE-RUST-EK wire shape, non-401 statuses pass through, non-embeddings domains pass through, missing-tag guardGGML_NATIVE=OFF cargo test -p openhuman --lib -- "observability"— 152 tests pass, 0 failGGML_NATIVE=OFF cargo check --manifest-path Cargo.toml— clean (pre-existing warnings only)cargo fmtappliedSummary by CodeRabbit