IBEX Harness
DocsBenchmarksBlogChangelogRoadmap
GitHub
IBEX Harness

Documentation

HTTP route inventoryAuth gRPC (ValidateToken, ValidateAgent)Health and metricsChat completionsErrors
API Reference›Errors
API Reference

Errors

Stable JSON error envelope for proxy HTTP responses — codes from packages/apierror per ADR-0013.

Every proxy JSON error uses the same envelope shape. Codes are UPPER_SNAKE_CASE strings from packages/apierror — never ad-hoc literals in handlers. Design record: ADR-0013.

Scope

This page covers proxy HTTP errors returned to integrators. Auth gRPC uses standard gRPC status codes; see Auth gRPC.

Envelope shape

JSON
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request validation failed",
    "detail": "One or more fields failed validation",
    "docs_url": "https://ibexharness.com/docs/api-reference/errors",
    "request_id": "019abc-def0-7890-abcd-ef1234567890",
    "timestamp": "2026-06-14T12:00:00.000Z",
    "field_errors": [
      {
        "field": "model",
        "code": "REQUIRED",
        "message": "model is required"
      }
    ]
  }
}
FieldAlways presentDescription
codeYesCanonical code from packages/apierror
messageYesSafe, human-readable summary
detailNoAdditional context (no secrets)
docs_urlNoSet when IBEX_ERROR_DOCS_BASE is configured
request_idYesUUID v4/v7 from packages/reqid
timestampYesUTC RFC 3339
field_errorsNoPresent on VALIDATION_ERROR

Field error codes

REQUIRED, TOO_LONG, TOO_MANY, INVALID_ENUM, INVALID_FORMAT

Response headers

All error responses include:

HeaderDescription
X-Request-IDSame value as error.request_id
X-Trace-IDSynthetic trace id until full OTel wiring
X-Response-TimeServer processing time in milliseconds

Configurable via IBEX_REQUEST_ID_HEADER and IBEX_TRACE_ID_HEADER.

Proxy error codes

Client errors (4xx)

HTTPCodeWhen
400INVALID_JSONMalformed JSON body
400VALIDATION_ERRORSemantic validation failure (+ field_errors)
400MISSING_AGENT_IDX-IBEX-Agent-ID missing on protected routes
401MISSING_TOKENNo Authorization header
401INVALID_TOKENBearer malformed, expired, or revoked
403INSUFFICIENT_PERMISSIONSToken lacks route permission
403AGENT_NOT_AUTHORIZEDAgent unknown or wrong org
403AGENT_SUSPENDEDAgent paused, suspended, or archived
405METHOD_NOT_ALLOWEDWrong HTTP method for route
413PAYLOAD_TOO_LARGEBody exceeds IBEX_MAX_REQUEST_BODY_BYTES (1 MiB)
415UNSUPPORTED_MEDIA_TYPEChat POST without application/json
429RATE_LIMITEDOrg RPM limit exceeded
409IDEMPOTENCY_KEY_REUSESame Idempotency-Key with a different request fingerprint
409IDEMPOTENCY_IN_PROGRESSSame key is still being processed — retry shortly

Server / dependency errors (5xx)

HTTPCodeWhen
501PROVIDER_NOT_CONFIGUREDRequested model is not registered in the active provider registry
503SERVICE_DEGRADEDAuth ValidateToken failed unexpectedly / deadline
503AUTH_UNAVAILABLEAuth ValidateAgent transport failure
500INTERNAL_ERRORUnhandled server fault

Provider / upstream errors

Upstream LLM failures are mapped by packages/provider.MapError into the same envelope (ADR-0026).

HTTPCodeWhen
400INVALID_REQUESTUpstream rejected the chat payload (sanitized detail only)
429RATE_LIMITEDUpstream provider throttled; Retry-After forwarded when present
503PROVIDER_UNAVAILABLEUpstream 401/403/404/5xx or transport failure (provider key issues are not client PAT 401)
504PROVIDER_TIMEOUTUpstream deadline exceeded

Proxy retries are exhaustive

The OpenAI adapter retries transient 429/5xx (and some transport errors) before returning. A client-visible PROVIDER_UNAVAILABLE / upstream RATE_LIMITED means those retries are already exhausted — aggressive client re-retry of the same request can amplify load. Prefer backoff and Retry-After when present.

Cross-tenant access

Cross-org resource access returns 403 AGENT_NOT_AUTHORIZED or INSUFFICIENT_PERMISSIONS — never 404 — to prevent enumeration attacks.

Examples

bash
curl -s -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[]}'
JSON
{
  "error": {
    "code": "MISSING_TOKEN",
    "message": "Authorization header is required",
    "request_id": "…",
    "timestamp": "…"
  }
}

Rate-limited responses include Retry-After and X-RateLimit-* headers with code RATE_LIMITED.

HTTP status mapping

Implemented in packages/apierror.HTTPStatus. Unknown codes default to 500.

1

Handler detects failure

Middleware or handler selects a Code from packages/apierror.

2

errors.Write / WriteFromRequest

Proxy internal layer delegates to apierror.Write with request_id from context.

3

Headers + JSON body

ResponseHeadersMiddleware sets X-Request-ID, X-Trace-ID, X-Response-Time.

Related

  • Chat completions — request shape and provider forward
  • HTTP route inventory — implemented paths
  • ADR-0013 — limits and middleware order

Was this page helpful?

Edit on GitHub

Last updated on

PreviousChat completionsNextArchitecture Decision Records

On this page

  • Envelope shape
  • Field error codes
  • Response headers
  • Proxy error codes
  • Client errors (4xx)
  • Server / dependency errors (5xx)
  • Provider / upstream errors
  • Examples
  • HTTP status mapping
  • Related
0%