Errors
This page is a human index of every ErrorCode and HTTP status the scaffold returns today. It is not a product commitment on limits. For the frozen HTTP inspect wire contract, defer to OpenAPI (ADR 0014 / #194). Repo source: docs/errors.md.
Error body
Section titled “Error body”Non-success classify responses that the handler builds use this JSON shape:
{ "request_id": "…", "error": "invalid_request", "message": "…"}| Field | Meaning |
|---|---|
request_id |
Same id the process associates with the request (also on success responses and typically as x-request-id) |
error |
Stable snake_case code from ErrorCode. Clients must key on this field (and the HTTP status). |
message |
Human-readable text from the server. It must not echo the submitted content or the idempotency key. Not a stable client contract. |
Codes and statuses
Section titled “Codes and statuses”error |
HTTP status | When this scaffold returns it |
|---|---|---|
invalid_request |
400 | Body is not a valid classify JSON object (including unknown fields / deserialize failure); content is empty; checks is empty; a check name is unknown; source is not recognized. After that validation, a missing Idempotency-Key or an invalid one |
unsupported_check |
422 | A check name is known to the contract but not registered in this build. prompt_injection and secrets are both registered, so this scaffold does not return this code for those names |
payload_too_large |
413 | After JSON parse, UTF-8 byte length of content exceeds the content cap (max_content_bytes, default 4096). This happens before any usage reservation |
unauthorized |
401 | Missing, malformed, unknown, mismatched, or revoked Bearer API key on classify or key routes. A transient database failure while looking the key up is not a 401: it returns detector_failed 503 (below) |
quota_exceeded |
429 | The period’s reserved and committed units plus this request would exceed the organization’s plan allowance. Not a published price |
rate_limited |
429 | A new classify attempt would exceed this organization’s short-window attempt cap, counted from usage_events. A committed retry and an in-flight key are not new attempts. Not a published price |
idempotency_in_progress |
409 | The same organization already has an in-flight reserved row for this Idempotency-Key |
misconfigured |
500 | API settings cannot be loaded, or max_content_bytes is configured as 0. Also: the organization has no active subscription, or the usage ledger holds inconsistent state, for example more than one active subscription period (usage reservation could not be completed) |
detector_failed |
503 | A registered detector failed to complete for a requested check. The inspect handler returns ErrorBody (not a success body). Distinct from Polar webhook empty-body 503. When no model artifact is configured, prompt_injection returns check failed to complete: prompt_injection. When a model is loaded, inference pool saturation returns check failed to complete: prompt_injection (inference saturated) and an open circuit breaker returns check failed to complete: prompt_injection (circuit breaker open). secrets does not depend on inference. The same code and status are returned, with message usage ledger is temporarily unavailable; retry the request, when the usage ledger cannot reach its database (for example a connection-pool timeout under load). The request is not served and no usage is charged, so retry with backoff. Also returned, with message authentication is temporarily unavailable; retry the request, when the API-key lookup cannot reach its database: the key was not judged, so retry rather than rotate it. Reusing this code for non-detector outages is deliberate while the enum is frozen (ADR 0014; a dedicated code is #401). Messages never include the submitted text |
Auth failures use the same body shape:
{ "request_id": "…", "error": "unauthorized", "message": "authentication required" }When the key lookup hits a transient database failure the response is 503, not 401:
{ "request_id": "…", "error": "detector_failed", "message": "authentication is temporarily unavailable; retry the request" }message must not echo the Authorization header or raw key. Do not invent codes in clients.
Unsupported checks and detector runtime failures fail the whole request: the handler does not return findings for other checks on the same call.
Transport limits (not ErrorCode values)
Section titled “Transport limits (not ErrorCode values)”Published limits, decided in ADR 0039 (context and latency target) and ADR 0040 (byte caps and timeouts).
| Limit | Value | Behavior |
|---|---|---|
Model context (prompt_injection) |
512-token encoded sequence (default; includes special tokens) | Longer text is right-truncated to fit; only the first part is scored, and the response sets prompt_injection_truncated when coverage is known |
| Content field | 4096 bytes (UTF-8) | Handler returns 413 + error: payload_too_large |
| HTTP body | 32 KiB (body_limit) |
Middleware may reject before the handler; callers may see 413 without an ErrorBody |
| Request timeout | 3 seconds | Framework timeout; not an ErrorBody / ErrorCode yet — do not assume JSON error schema |
| Inference timeout | 2 seconds (default; queue wait 0.5 seconds) | The detector fails closed: 503 + error: detector_failed |
Latency target, not an SLA: for prompt_injection, warm, one request in flight, p50 at most 100 ms and p95 at most 500 ms. The basis is a local Linux container on an Apple M2 (aarch64) capped at 2 vCPU and 3 GiB, covering tokenization and inference only (not authentication, usage accounting or network). Latency at 512 tokens is unmeasured; the evidence is inputs with a median of 32 tokens and a maximum of 370. There is no p99 or cold-start target. The 3 s, 2 s and 0.5 s timeouts were chosen, not measured.
Not covered here
Section titled “Not covered here”- Polar webhook transport failures use empty-body
403(bad signature) or503(secret missing). Outbound Polar routes useErrorBodywithinvalid_request(polar product must be free,polar subscription not found) ormisconfigured(polar is not configured, HTTP 500). Reconcile mismatches are a200body, not an error code. No published price is charged (#165 / ADR 0012) - SDK generation. OpenAPI documents this schema under the frozen
POST /v1/inspectcontract (ADR 0014);/v1/classifyis not mounted. SDKs remain in-repo / not registry-published