The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(inference): route http error demotion through shared failure facts
Steven Enamakel1406b88fdff3
diff --git a/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rs b/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rsindex 113b708ecd..532b8d03ee 100644--- a/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rs+++ b/crates/openhuman-core/src/core/observability_crash_filter_integrations_tests.rs@@ -631,7 +631,7 @@ fn ollama_cloud_internal_500_reraise_routes_through_expected_path() {// `domain=agent` half of the flood is suppressed too.let reraise = tinyinference_llm::failure::ollama_cloud_internal_500_user_message(Some("minimax-m3:cloud"),- reqwest::StatusCode::INTERNAL_SERVER_ERROR,+ 500,);assert_eq!(expected_error_kind(&reraise),@@ -653,7 +653,7 @@ fn ollama_cloud_internal_500_before_send_matches_raw_and_reraised_shapes() {let reraise = tinyinference_llm::failure::ollama_cloud_internal_500_user_message(None,- reqwest::StatusCode::INTERNAL_SERVER_ERROR,+ 500,);assert!(is_ollama_cloud_internal_500_event(&event_with_message(&reraisediff --git a/crates/openhuman-core/src/inference/provider/ops/http_error.rs b/crates/openhuman-core/src/inference/provider/ops/http_error.rsindex 763f2a58ec..ae957469c6 100644--- a/crates/openhuman-core/src/inference/provider/ops/http_error.rs+++ b/crates/openhuman-core/src/inference/provider/ops/http_error.rs@@ -11,7 +11,7 @@ mod tests;use crate::inference::provider::openhuman_backend_model;use tinyinference_core::sanitize::sanitize_api_error;use tinyinference_llm::failure::http::{- classify_and_report_http_failure, ErrorReporter, ProviderHttpFailure,+ classify_and_report_http_failure, ErrorReporter, ProviderHttpFailure, ProviderHttpFailureFacts,};use tinyinference_llm::failure::{local_provider_no_model_loaded_user_message, ollama_cloud_internal_500_user_message,@@ -35,6 +35,14 @@ pub fn is_backend_error_code_owned(provider: &str, body: &str) -> bool {&& crate::inference::provider::backend_error_code_skips_sentry(body)}+/// Config-rejection demotion policy: the managed backend's unknown-model body+/// is user-state on every provider; the remaining rejection phrases stay+/// third-party scoped so a backend regression still reaches Sentry.+pub(crate) fn config_rejection_demoted(facts: &ProviderHttpFailureFacts, provider: &str) -> bool {+ facts.configuration_rejected+ && (facts.unknown_model || provider != openhuman_backend_model::PROVIDER_LABEL)+}+fn log_user_state(level_warn: bool,kind: &str,@@ -46,14 +54,26 @@ fn log_user_state() {if level_warn {tracing::warn!(- domain = "llm_provider", operation, provider, model = model.unwrap_or(""),- status, failure = "non_2xx", kind, reason,+ domain = "llm_provider",+ operation,+ provider,+ model = model.unwrap_or(""),+ status,+ failure = "non_2xx",+ kind,+ reason,"[llm_provider] {operation} {reason} ({status}) — not reporting to Sentry");} else {tracing::info!(- domain = "llm_provider", operation, provider, model = model.unwrap_or(""),- status, failure = "non_2xx", kind, reason,+ domain = "llm_provider",+ operation,+ provider,+ model = model.unwrap_or(""),+ status,+ failure = "non_2xx",+ kind,+ reason,"[llm_provider] {operation} {reason} ({status}) — not reporting to Sentry");}@@ -131,23 +151,36 @@ impl ErrorReporter for HostErrorReporter<'_> {let demote = |kind: &str, reason: &str, warn: bool| {log_user_state(warn, kind, reason, operation, provider, model, status);};- // The managed backend's unknown-model body is user-state on every- // provider; the remaining config-rejection phrases stay third-party- // scoped so a backend regression still reaches Sentry.- let config_rejected = facts.configuration_rejected && (facts.unknown_model || !is_backend);+ let config_rejected = config_rejection_demoted(&facts, provider);if matches!(status, 401 | 403) && is_backend {publish_backend_session_expired(operation, provider, status_code, self.message);} else if facts.budget_exhausted {demote("budget", "budget-exhausted 400", false);} else if facts.no_model_loaded {- demote("provider_user_state", "local_provider_no_model_loaded", false);+ demote(+ "provider_user_state",+ "local_provider_no_model_loaded",+ false,+ );} else if facts.custom_upstream_bad_request {- demote("provider_user_state", "custom_openai_upstream_bad_request", false);+ demote(+ "provider_user_state",+ "custom_openai_upstream_bad_request",+ false,+ );} else if facts.access_policy_denied {- demote("provider_access_policy", "provider access-policy 403", false);+ demote(+ "provider_access_policy",+ "provider access-policy 403",+ false,+ );} else if config_rejected {- demote("provider_config_rejection", "provider config-rejection", false);+ demote(+ "provider_config_rejection",+ "provider config-rejection",+ false,+ );} else if facts.context_window_exceeded {demote("context_window_exceeded", "context-window exceeded", true);} else if facts.quota_exhausted {@@ -159,11 +192,23 @@ impl ErrorReporter for HostErrorReporter<'_> {} else if facts.oauth_session_expired && !is_backend {demote("provider_user_state", "openai_oauth_session_expired", false);} else if facts.insufficient_credits {- demote("insufficient_credits", "provider insufficient-credits 402", false);+ demote(+ "insufficient_credits",+ "provider insufficient-credits 402",+ false,+ );} else if facts.ollama_cloud_internal_error {- demote("ollama_cloud_internal_500", "Ollama Cloud hosted-inference 500", false);+ demote(+ "ollama_cloud_internal_500",+ "Ollama Cloud hosted-inference 500",+ false,+ );} else if facts.moderation_rejected {- demote("external_moderation_rejection", "external content-moderation rejection", false);+ demote(+ "external_moderation_rejection",+ "external content-moderation rejection",+ false,+ );} else if should_report_provider_http_status(status) {let status_str = status.to_string();crate::core::observability::report_error(diff --git a/crates/openhuman-core/src/inference/provider/ops/http_error_tests.rs b/crates/openhuman-core/src/inference/provider/ops/http_error_tests.rsindex 361f06acc0..1a085714dd 100644--- a/crates/openhuman-core/src/inference/provider/ops/http_error_tests.rs+++ b/crates/openhuman-core/src/inference/provider/ops/http_error_tests.rs@@ -13,7 +13,7 @@ fn response(status: StatusCode, body: &str) -> reqwest::Response {/// Drain the shared bus until `pick` matches an event or the queue is empty.fn drain_until<T>(- rx: &mut tinybus::Receiver<DomainEvent>,+ rx: &mut tinybus::EventReceiver<DomainEvent>,mut pick: impl FnMut(DomainEvent) -> Option<T>,) -> Option<T> {loop {@@ -68,7 +68,10 @@ async fn api_error_replaces_no_model_loaded_body_with_guidance() {),).await;- assert!(err.to_string().to_ascii_lowercase().contains("load a model"));+ assert!(err+ .to_string()+ .to_ascii_lowercase()+ .contains("load a model"));}#[tokio::test]@@ -140,5 +143,8 @@ async fn backend_provider_does_not_get_byo_key_rejection() {}_ => None,});- assert!(rejected.is_none(), "backend 401 is session expiry, not a BYO key");+ assert!(+ rejected.is_none(),+ "backend 401 is session expiry, not a BYO key"+ );}diff --git a/crates/openhuman-core/src/inference/provider/ops/mod.rs b/crates/openhuman-core/src/inference/provider/ops/mod.rsindex e06f81081a..0bfdcce991 100644--- a/crates/openhuman-core/src/inference/provider/ops/mod.rs+++ b/crates/openhuman-core/src/inference/provider/ops/mod.rs@@ -12,10 +12,11 @@ mod provider_factory;// ── public surface (preserves the original `pub use ops::*` contract) ──+#[cfg(test)]+pub(crate) use http_error::config_rejection_demoted;pub use http_error::{- api_error, is_backend_auth_failure, is_backend_error_code_owned,- log_byo_provider_auth_failure, publish_backend_session_expired,- should_report_provider_http_failure,+ api_error, is_backend_auth_failure, is_backend_error_code_owned, log_byo_provider_auth_failure,+ publish_backend_session_expired, should_report_provider_http_failure,};pub use models::{diff --git a/crates/openhuman-core/src/inference/provider/ops_tests.rs b/crates/openhuman-core/src/inference/provider/ops_tests.rsindex dff71dede4..1d06c87593 100644--- a/crates/openhuman-core/src/inference/provider/ops_tests.rs+++ b/crates/openhuman-core/src/inference/provider/ops_tests.rs@@ -16,7 +16,6 @@ use std::sync::{};use tempfile::TempDir;use tinyinference_core::sanitize::{sanitize_api_error, MAX_API_ERROR_CHARS};-use tinyinference_llm::providers::openai::codex::openai_codex_client_version;#[derive(Clone)]struct ModelProbeState {diff --git a/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rs b/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rsindex 867b8dfc4e..369fc61a4c 100644--- a/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rs+++ b/crates/openhuman-core/src/inference/provider/ops_tests_error_suppression_tests.rs@@ -38,54 +38,6 @@ fn list_configured_models_accepts_slug() {assert!(found_by_id.is_some(), "id lookup must still work");}-#[test]-fn openrouter_detection_matches_builtin_slug_or_host() {- let provider = |slug: &str, endpoint: &str| CloudProviderCreds {- id: format!("p_{slug}"),- slug: slug.to_string(),- label: slug.to_string(),- endpoint: endpoint.to_string(),- auth_style: AuthStyle::Bearer,- default_model: None,- };-- assert!(is_openrouter_provider(&provider(- "openrouter",- "http://127.0.0.1:1234"- )));- assert!(is_openrouter_provider(&provider(- "custom-router",- "https://openrouter.ai/api/v1"- )));- assert!(is_openrouter_provider(&provider(- "custom-router",- "https://oauth.openrouter.ai/api/v1"- )));- assert!(!is_openrouter_provider(&provider(- "custom-openai",- "https://api.openai.com/v1"- )));-}--#[test]-fn openai_codex_models_url_includes_client_version_query() {- let url = append_query_param(- "https://chatgpt.com/backend-api/codex/models",- "client_version",- &openai_codex_client_version(),- );- let parsed = reqwest::Url::parse(&url).expect("url");-- assert_eq!(parsed.path(), "/backend-api/codex/models");- assert_eq!(- parsed- .query_pairs()- .find(|(key, _)| key == "client_version")- .map(|(_, value)| value.into_owned()),- Some(openai_codex_client_version().to_string())- );-}-#[tokio::test]async fn openrouter_invalid_key_fails_before_models_catalog_probe() {let tmp = tempfile::tempdir().expect("tempdir");@@ -249,96 +201,7 @@ fn backend_error_code_owned_gates_managed_errors_except_malformed_bad_request()));}-// Confirm the budget-exhausted suppression predicate is scoped correctly.-// These tests exercise the real production function, not a duplicate.-mod budget_exhausted_suppression {- use super::super::*;-- const BUDGET_BODY: &str = "Insufficient budget";- const UNRELATED_BODY: &str = "Invalid request: model not found";-- #[test]- fn budget_exhausted_400_is_suppressed() {- assert!(is_budget_exhausted_http_400(- reqwest::StatusCode::BAD_REQUEST,- BUDGET_BODY,- ));- }-- #[test]- fn budget_exhausted_400_is_case_insensitive() {- assert!(is_budget_exhausted_http_400(- reqwest::StatusCode::BAD_REQUEST,- "budget exceeded — ADD credits to continue",- ));- }-- #[test]- fn budget_exhausted_500_is_not_suppressed() {- // A 500 is a server bug, not expected user-state — keep reporting.- assert!(!is_budget_exhausted_http_400(- reqwest::StatusCode::INTERNAL_SERVER_ERROR,- BUDGET_BODY,- ));- }-- #[test]- fn budget_exhausted_400_unrelated_body_is_not_suppressed() {- assert!(!is_budget_exhausted_http_400(- reqwest::StatusCode::BAD_REQUEST,- UNRELATED_BODY,- ));- }-- #[test]- fn budget_exhausted_402_is_not_suppressed() {- assert!(!is_budget_exhausted_http_400(- reqwest::StatusCode::PAYMENT_REQUIRED,- BUDGET_BODY,- ));- }-- #[test]- fn budget_exhausted_empty_body_is_not_suppressed() {- assert!(!is_budget_exhausted_http_400(- reqwest::StatusCode::BAD_REQUEST,- "",- ));- }-}--mod provider_access_policy_suppression {- use super::super::*;-- const ACCESS_TERMINATED_BODY: &str =- "{\"error\":{\"message\":\"Kimi For Coding is currently only available for Coding Agents.\",\"type\":\"access_terminated_error\"}}";-- #[test]- fn access_terminated_403_is_suppressed() {- assert!(is_provider_access_policy_denied_http_403(- reqwest::StatusCode::FORBIDDEN,- ACCESS_TERMINATED_BODY,- ));- }-- #[test]- fn access_terminated_non_403_is_not_suppressed() {- assert!(!is_provider_access_policy_denied_http_403(- reqwest::StatusCode::BAD_REQUEST,- ACCESS_TERMINATED_BODY,- ));- }-- #[test]- fn unrelated_403_is_not_suppressed() {- assert!(!is_provider_access_policy_denied_http_403(- reqwest::StatusCode::FORBIDDEN,- "{\"error\":{\"message\":\"forbidden\"}}",- ));- }-}--// Exercises the real `is_provider_config_rejection_http` decision used+// Exercises the real `config_rejection_demoted` decision used// by `api_error`, including the inverted provider-aware polarity.mod provider_config_rejection_suppression {use super::super::*;@@ -352,21 +215,30 @@ mod provider_config_rejection_suppression {#[test]fn custom_provider_4xx_config_rejection_is_suppressed() {- assert!(is_provider_config_rejection_http(- reqwest::StatusCode::BAD_REQUEST,- "custom_openai",- TIER_LEAK_BODY,+ assert!(config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ "custom_openai",+ reqwest::StatusCode::BAD_REQUEST.as_u16(),+ TIER_LEAK_BODY+ ),+ "custom_openai"));- assert!(is_provider_config_rejection_http(- reqwest::StatusCode::BAD_REQUEST,- "custom_openai",- TEMP_BODY,+ assert!(config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ "custom_openai",+ reqwest::StatusCode::BAD_REQUEST.as_u16(),+ TEMP_BODY+ ),+ "custom_openai"));// 404 "model does not exist" is the same user-config class.- assert!(is_provider_config_rejection_http(- reqwest::StatusCode::NOT_FOUND,- "custom_openai",- "The model `gpt-5.5` does not exist or you do not have access to it.",+ assert!(config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ "custom_openai",+ reqwest::StatusCode::NOT_FOUND.as_u16(),+ "The model `gpt-5.5` does not exist or you do not have access to it."+ ),+ "custom_openai"));}@@ -378,15 +250,21 @@ mod provider_config_rejection_suppression {// mean we sent it a bad request — a real regression that// must still reach Sentry. (Mirror of the 401/403 backend// rule.)- assert!(!is_provider_config_rejection_http(- reqwest::StatusCode::BAD_REQUEST,- openhuman_backend_model::PROVIDER_LABEL,- TIER_LEAK_BODY,+ assert!(!config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ openhuman_backend_model::PROVIDER_LABEL,+ reqwest::StatusCode::BAD_REQUEST.as_u16(),+ TIER_LEAK_BODY+ ),+ openhuman_backend_model::PROVIDER_LABEL));- assert!(!is_provider_config_rejection_http(- reqwest::StatusCode::BAD_REQUEST,- openhuman_backend_model::PROVIDER_LABEL,- TEMP_BODY,+ assert!(!config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ openhuman_backend_model::PROVIDER_LABEL,+ reqwest::StatusCode::BAD_REQUEST.as_u16(),+ TEMP_BODY+ ),+ openhuman_backend_model::PROVIDER_LABEL));}@@ -408,10 +286,13 @@ mod provider_config_rejection_suppression {r#"OpenHuman API error (400 Bad Request): {"success":false,"error":"Model 'custom:MiniMax-M2.7' is not available. Use GET /openai/v1/models to list available models."}"#,] {assert!(- is_provider_config_rejection_http(- reqwest::StatusCode::BAD_REQUEST,- openhuman_backend_model::PROVIDER_LABEL,- body,+ config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ openhuman_backend_model::PROVIDER_LABEL,+ reqwest::StatusCode::BAD_REQUEST.as_u16(),+ body+ ),+ openhuman_backend_model::PROVIDER_LABEL),"TAURI-RUST-2Z1 body must be suppressed for openhuman backend: {body:?}");@@ -421,10 +302,13 @@ mod provider_config_rejection_suppression {#[test]fn server_error_is_not_suppressed() {// A 5xx is a server bug, not user-config — keep reporting.- assert!(!is_provider_config_rejection_http(- reqwest::StatusCode::INTERNAL_SERVER_ERROR,- "custom_openai",- TIER_LEAK_BODY,+ assert!(!config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ "custom_openai",+ reqwest::StatusCode::INTERNAL_SERVER_ERROR.as_u16(),+ TIER_LEAK_BODY+ ),+ "custom_openai"));}@@ -432,19 +316,25 @@ mod provider_config_rejection_suppression {fn transient_429_is_not_suppressed_here() {// 429 is transient; handled by should_report_provider_http_failure,// not this classifier (must not be swallowed as user-config).- assert!(!is_provider_config_rejection_http(- reqwest::StatusCode::TOO_MANY_REQUESTS,- "custom_openai",- TIER_LEAK_BODY,+ assert!(!config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ "custom_openai",+ reqwest::StatusCode::TOO_MANY_REQUESTS.as_u16(),+ TIER_LEAK_BODY+ ),+ "custom_openai"));}#[test]fn unrelated_4xx_body_is_not_suppressed() {- assert!(!is_provider_config_rejection_http(- reqwest::StatusCode::BAD_REQUEST,- "custom_openai",- "Bad request: missing required field 'messages'",+ assert!(!config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ "custom_openai",+ reqwest::StatusCode::BAD_REQUEST.as_u16(),+ "Bad request: missing required field 'messages'"+ ),+ "custom_openai"));}@@ -460,11 +350,7 @@ mod provider_config_rejection_suppression {// Verbatim wire body from TAURI-RUST-4XK Sentry issue 5338.let body = r#"ollama API error (403 Forbidden): {"error":"this model requires a subscription, upgrade for access: https://ollama.com/upgrade (ref: bc48f3c8-fba1-40b6-93a9-786a167d16f9)"}"#;assert!(- is_provider_config_rejection_http(- reqwest::StatusCode::FORBIDDEN,- "ollama",- body,- ),+ config_rejection_demoted(&tinyinference_llm::failure::http::classify_http_failure("ollama", reqwest::StatusCode::FORBIDDEN.as_u16(), body), "ollama"),"TAURI-RUST-4XK: ollama 403 subscription-gate must be classified as provider config-rejection");}@@ -477,43 +363,17 @@ mod provider_config_rejection_suppression {// expected backend body, so this is purely defensive.let body = r#"{"error":"this model requires a subscription, upgrade for access: https://ollama.com/upgrade (ref: test)"}"#;assert!(- !is_provider_config_rejection_http(- reqwest::StatusCode::FORBIDDEN,- openhuman_backend_model::PROVIDER_LABEL,- body,+ !config_rejection_demoted(+ &tinyinference_llm::failure::http::classify_http_failure(+ openhuman_backend_model::PROVIDER_LABEL,+ reqwest::StatusCode::FORBIDDEN.as_u16(),+ body+ ),+ openhuman_backend_model::PROVIDER_LABEL),"backend 403 subscription phrase must NOT be suppressed (polarity guard)");}-- #[test]- fn log_helper_runs_without_panicking() {- // Covers the demotion log path taken by `api_error` when a- // custom provider rejects the user's model/param config. No- // tracing subscriber in unit tests, so this is a pure smoke.- log_provider_config_rejection(- "api_error",- "custom_openai",- Some("reasoning-v1"),- reqwest::StatusCode::BAD_REQUEST,- );- }-}--mod context_window_exceeded_suppression {- use super::super::*;-- #[test]- fn log_helper_runs_without_panicking() {- // Smoke for the demotion path taken by `api_error` — no tracing- // subscriber in unit tests.- log_context_window_exceeded(- "api_error",- "custom_openai",- None,- reqwest::StatusCode::INTERNAL_SERVER_ERROR,- );- }}#[test]diff --git a/crates/openhuman-core/src/inference/provider/ops_tests_models_parsing_tests.rs b/crates/openhuman-core/src/inference/provider/ops_tests_models_parsing_tests.rsindex 809881cd99..5abfcfe236 100644--- a/crates/openhuman-core/src/inference/provider/ops_tests_models_parsing_tests.rs+++ b/crates/openhuman-core/src/inference/provider/ops_tests_models_parsing_tests.rs@@ -149,107 +149,6 @@ fn is_backend_auth_failure_only_matches_openhuman_backend_401_403() {}}-/// `is_byo_provider_auth_failure_http` demotes a non-backend provider's-/// 401/403 from Sentry when the body looks like a missing/invalid BYO API-/// key (TAURI-RUST-DHM: a `kiro` custom provider with no key flooded Sentry-/// with 5,636 identical events from one user via a background retry loop).-/// The gate is provider-scoped (backend keeps its SessionExpired branch) and-/// body-shape-anchored (a non-auth 401, e.g. quota / geo-block, still reports).-#[test]-fn byo_provider_auth_failure_demotes_authentication_error_bodies() {- use reqwest::StatusCode;-- // The exact kiro 401 envelope from the Sentry report.- let kiro_body =- r#"{"error":{"message":"Invalid or missing API key","type":"authentication_error"}}"#;- assert!(is_byo_provider_auth_failure_http(- "kiro",- StatusCode::UNAUTHORIZED,- kiro_body- ));- // 403 with the same envelope is demoted too.- assert!(is_byo_provider_auth_failure_http(- "kiro",- StatusCode::FORBIDDEN,- kiro_body- ));-- // Every recognised auth-key marker across the BYO providers in Sentry.- for body in [- r#"{"error":{"type":"authentication_error"}}"#,- r#"{"error":{"code":"invalid_api_key","message":"Incorrect API key provided"}}"#,- "Invalid API key",- "invalid or missing api key",- "missing api key",- r#"{"message":"no api key supplied"}"#,- "invalid authentication",- ] {- assert!(- is_byo_provider_auth_failure_http("custom_openai", StatusCode::UNAUTHORIZED, body),- "BYO auth body must be demoted: {body}"- );- }-}--/// The backend keeps its `is_backend_auth_failure` → SessionExpired branch:-/// a backend 401 with an auth-error body must NOT be swallowed here, or the-/// session-expiry reauth path (and its existing test) would silently break.-#[test]-fn byo_provider_auth_failure_excludes_openhuman_backend() {- use reqwest::StatusCode;- let backend = crate::inference::provider::openhuman_backend_model::PROVIDER_LABEL;- let body = r#"{"error":{"type":"authentication_error"}}"#;- assert!(!is_byo_provider_auth_failure_http(- backend,- StatusCode::UNAUTHORIZED,- body- ));- assert!(!is_byo_provider_auth_failure_http(- backend,- StatusCode::FORBIDDEN,- body- ));-}--/// Body-shape anchoring: a 401/403 whose body is NOT an auth-key envelope-/// (quota, geo-block, opaque gateway text) still reaches Sentry — the gate-/// keys on the body, not the bare status. And a non-401/403 status with an-/// auth-ish body is out of scope (handled by the budget / config-rejection-/// branches or the status gate).-#[test]-fn byo_provider_auth_failure_is_body_and_status_scoped() {- use reqwest::StatusCode;-- // 401/403 without an auth-key envelope — still actionable, must report.- for body in [- r#"{"error":{"message":"Access denied for your region","type":"forbidden"}}"#,- r#"{"error":{"message":"Quota exceeded for this account"}}"#,- "Unauthorized",- ] {- assert!(- !is_byo_provider_auth_failure_http("custom_openai", StatusCode::UNAUTHORIZED, body),- "non-auth-envelope body must stay reportable: {body}"- );- }-- // Auth-shaped body on a non-401/403 status is out of this predicate's scope.- for status in [- StatusCode::BAD_REQUEST,- StatusCode::TOO_MANY_REQUESTS,- StatusCode::INTERNAL_SERVER_ERROR,- StatusCode::NOT_FOUND,- ] {- assert!(- !is_byo_provider_auth_failure_http(- "custom_openai",- status,- r#"{"error":{"type":"authentication_error"}}"#- ),- "status {status} with auth body must not be demoted here"- );- }-}-/// End-to-end through `api_error`: a non-backend 401 with an auth-error body/// returns the sanitized provider error (so the chat/UI surface is unchanged)/// while the BYO-auth branch demotes it from Sentry. Exercises the wired-in