fix(observability): classify DeepSeek 'Insufficient Balance' 402 as user-state (Sentry TAURI-RUST-4ZF)#2809
Conversation
…ser-state (Sentry TAURI-RUST-4ZF)
Add `"insufficient balance"` to the `is_provider_config_rejection_message`
PHRASES array. A user's custom BYO-key DeepSeek provider returns HTTP 402
`{"error":{"message":"… Insufficient Balance …"}}` when their DeepSeek
account balance is exhausted. Pure user-billing state — the remediation
is "top up the DeepSeek account", which Sentry has no way to act on.
This is the same class as the OpenRouter S5 "requires more credits" 402
already in the list — different upstream, different wire token. The
OpenHuman backend's own balance gate is handled separately by
`is_budget_exhausted_message` (different body shape), so there's no
backend false-positive risk: "Insufficient Balance" is a
DeepSeek-specific token our backend never emits.
Tests:
- `detects_insufficient_balance_402_family` — verbatim TAURI-RUST-4ZF
wire shape (issue 5679, model=ds/deepseek-v4-flash) + bare envelope.
- Existing `ignores_transient_and_server_and_unrelated` still green —
`"insufficient budget — add credits"` ("budget" ≠ "balance") and the
other negatives stay unclassified.
## Related
PR tinyhumansai#2796 (Sentry TAURI-RUST-35 family, "does not support tools") also
appends to this PHRASES array but at a different position (end of list
vs. next to the S5 entry) — no merge conflict expected.
## Test plan
- [x] `cargo test detects_insufficient_balance_402_family` — passes
- [x] `cargo test config_rejection` — 7 tests pass, 0 regressions
- [x] `cargo check --bin openhuman-core` — passes
- [x] `cargo fmt --check` — clean
|
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 (1)
📝 WalkthroughWalkthroughThis PR extends the provider configuration-rejection classifier to recognize DeepSeek custom BYO-key 402 failures where the upstream error message contains "Insufficient Balance". The changes include classifier logic updates, module documentation, and test coverage for two wire-shape variants. ChangesDeepSeek Balance Exhaustion Classification
Possibly related PRs
Suggested labels
Suggested reviewers
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
Add
"insufficient balance"tois_provider_config_rejection_message's PHRASES array (src/openhuman/inference/provider/config_rejection.rs). A user's custom BYO-key DeepSeek provider returns HTTP 402{"error":{"message":"… Insufficient Balance …"}}when their DeepSeek account balance is exhausted. Pure user-billing state — the remediation is "top up the DeepSeek account", which Sentry has no way to act on.Targets Sentry TAURI-RUST-4ZF (
domain=llm_provider,operation=native_chat,status=402,provider=custom,model=ds/deepseek-v4-flash).Why this belongs in the existing classifier
This is the same class as the OpenRouter S5
"requires more credits"402 already in the list — third-party BYO-key provider reporting the user is out of credits. Different upstream, different wire token:requires more creditsInsufficient BalanceThe OpenHuman backend's own balance gate is handled separately by
is_budget_exhausted_message(different body shape), so there's no backend false-positive risk:"Insufficient Balance"is a DeepSeek-specific token our backend never emits. The matcher is case-insensitive (body.to_ascii_lowercase()), so capitalisation variants are covered.Tests
detects_insufficient_balance_402_family— verbatim TAURI-RUST-4ZF wire shape (truncated body from issue 5679) + a bare upstream envelope.ignores_transient_and_server_and_unrelatedstays green — its negative case"insufficient budget — add credits"does NOT match ("budget"≠"balance"), so the new phrase doesn't over-reach.Related
PR #2796 (Sentry TAURI-RUST-35 family, "does not support tools") also appends to this PHRASES array, but at a different position (end of list vs. next to the S5 entry) — no merge conflict expected.
Test plan
cargo test detects_insufficient_balance_402_family— passescargo test config_rejection— 7 tests pass, 0 regressionscargo check --manifest-path Cargo.toml --bin openhuman-core— passescargo fmt --check— cleanNote on push: the pre-push hook failed on pre-existing ESLint warnings in
app/src/components/BootCheckGate/BootCheckGate.tsxandRotatingTetrahedronCanvas.tsx(react-hooks/set-state-in-effect) — frontend React files untouched by this Rust-only change. Pushed with--no-verifyper the CLAUDE.md guidance for unrelated pre-existing breakage.Summary by CodeRabbit