Skip to main content

Module net

Module net 

Source
Expand description

Error classification for the OpenAI-compat / Codex provider routes.

Historically every error escaping try_route was blanket-wrapped in RuntimeError::Config("openai provider: …") — so a transient network blip against chatgpt.com/backend-api/codex/responses surfaced to the user as “Config error”, implying their configuration was broken (real incident: session 20260714-025948-3dab). This module classifies provider-route errors into honest categories:

  • transport failures (reqwest::Error) → RuntimeError::ApiStatus with a host-aware humanized message that preserves the full cause chain
  • upstream HTTP status failures (codex request failed: 503: …) → RuntimeError::ApiStatus
  • cancellation → RuntimeError::Canceled
  • everything else (missing keys, malformed tokens, …) → genuine RuntimeError::Config, same prefix as before

Functions§

provider_error_to_runtime
Classify an error escaping the OpenAI/Codex provider route into the right RuntimeError variant. Also logs the full cause chain at WARN — provider-route failures were previously invisible in the logs.
provider_error_to_runtime_for
Like provider_error_to_runtime, but qualified_model (e.g. kimi-code/k3) lets a vetted broker status label such as provider request failed: 403 Forbidden [access_terminated_error] be rendered as an actionable, provider-aware message. The label is one of OUR static constants (selected broker-side, never provider bytes) and the humanizer only ever returns our own text; the raw prefix message is kept for the log line.

Type Aliases§

BoxedProviderError
Boxed error type produced by the provider routes.