Fix/embeddings OpenAI expected error reporting#2190
Conversation
…ssifier to improve observability
|
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)
📝 WalkthroughWalkthroughOpenAiEmbedding::embed now routes non-success HTTP responses through ChangesError observability classification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
graycyrus
left a comment
There was a problem hiding this comment.
Walkthrough
Clean, well-scoped fix. Switches the openai embedding non-2xx diagnostic emit from report_error → report_error_or_expected so the existing ExpectedErrorKind::BudgetExhausted classifier runs at the call site instead of synthesizing a Sentry event that gets dropped by before_send (or, on pre-#1633 builds, flows straight through). This aligns the openai embedding provider with every other expected-error call site in the codebase. Regression test is solid.
| File | Change | Description |
|---|---|---|
src/openhuman/embeddings/openai.rs |
Bug fix | report_error → report_error_or_expected for non-2xx responses |
src/openhuman/embeddings/openai_tests.rs |
Test | New embed_budget_exhausted_400_still_errors — mocked 400 with budget-exhausted body, asserts error propagation preserved |
No findings — LGTM. Nice job keeping the scope tight and adding the regression test.
Summary
Problem
OPENHUMAN-TAURI-JM — 136 events on openhuman@0.53.43+2b64ea8ac567 with the message:
Embedding API error 400 Bad Request: {"success":false,"error":"Budget exceeded — add credits to continue"}
This is a deterministic user-state condition (the user is out of credits) that the UI already surfaces as an actionable toast — Sentry has no remediation path, and one event fires per failed embed call across the entire memory-embedding pipeline. The phrasing was already recognized by is_budget_exhausted_message and bucketed as ExpectedErrorKind::BudgetExhausted, and PR #1633 added the is_budget_event before_send filter as defense-in-depth — but:
Solution
src/openhuman/embeddings/openai.rs — Switch the non-2xx diagnostic emit from report_error → report_error_or_expected. The classifier inspects the formatted message, matches the budget-exhausted phrase ("budget exceeded", "add credits", "insufficient balance"), and demotes to tracing::info! with kind = "budget" — no Sentry event is created. Other expected variants (API-key-missing, transient upstream HTTP, network-unreachable) are handled by the same classifier as a free bonus.
src/openhuman/embeddings/openai_tests.rs — Add embed_budget_exhausted_400_still_errors, which spins up a mock returning HTTP 400 with the canonical backend body and asserts the propagated error preserves both the status code and the "Budget exceeded" phrase so upstream short-circuit logic can still pattern-match on it.
Design notes
Submission Checklist
If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.
Impact
Related
Summary by CodeRabbit
Bug Fixes
Tests