Skip to content

Error Flow

This page explains how internal failures become compact client-facing HTTP or SSE errors.

Typed error
IngressError / RequestError / TranslationError / StreamTranslationError / application errors
Classify
Select stable client-facing error type and status
Preserve safe details
Keep useful upstream headers without leaking private data
Render
HTTP body or SSE error event depending on response state
Client error
text or JSON ErrorResponseSpec
Error familyUse for
JsonPayloadErrorShared core JSON path, pretty source location, and deserialization source details.
IngressErrorCarrier-independent structured request normalization and validation failures.
RequestErrorApplication HTTP body/path failures and transparent wrapping of IngressError.
ConfigErrorConfig loading, config-file reads, route/provider validation, and startup config failures.
InternalErrorProxy runtime invariants, local filesystem IO, body reads, serialization, and boundary failures.
UpstreamErrorProvider send failures, non-success statuses, and upstream body-read failures.
TranslationErrorNon-streaming protocol payload conversion failures.
StreamTranslationErrorStructured stream conversion and lifecycle semantic failures.
SseErrorApplication SSE carrier parsing failures.
ByteStreamErrorByte stream carrier failures.

Core operations return typed errors when processing cannot continue. Legal adaptations and representational loss emit typed Observation values through Observer. Core must not both emit an observation and return the same failure; the application boundary observes, diagnoses, and renders a returned error once with HTTP/SSE context.

RuleReason
Do not expose internal taxonomy verbatimClient-facing types should be stable and compact.
Always include numeric status in payloadSSE error events cannot change HTTP status after streaming starts.
Preserve useful upstream diagnostic headers when presentRetry-After, upstream request ids, and rate-limit headers help debugging.
Do not fabricate upstream code or paramThose values only exist when the upstream provided them.
Do not log private request bodies or Authorization headersErrors must remain privacy-safe by default.
CarrierBehavior
HTTP before response startsRender normal HTTP error with configured text or JSON payload.
SSE after stream startsRender protocol-compatible error event where possible; include payload status.
Upstream non-2xxProject upstream failure into configured client-facing error format and safe preserved headers.
Stream semantic failureEmit/return an error that distinguishes incomplete terminal semantics from normal completion.
ConcernOwner
Shared core JSON error detailscrates/proxai-core/src/error.rs
Core ingress errorscrates/proxai-core/src/ingress/error.rs
Core translation errorscrates/proxai-core/src/translation/error.rs and translation/stream.rs
Application error composition and renderingsrc/error/
SSE carrier failuressrc/sse.rs and src/sse_translation.rs
Byte stream carrierssrc/http_support/
Proxy request lifecyclesrc/lib.rs and pipeline modules