Error Matrix By Status

Overview

How to mix shared COMMON_* errors with entity codes (e.g. USER_*), and how to review routers by HTTP status.

Rule of thumb

Where to define reusable responses

Service-wide common pool (recommended baseline)

HTTP status Code(s) Key(s) Reuse scope
401 COMMON_401 SECURITY_AUTH_REQUIRED All protected endpoints.
413 COMMON_413 SECURITY_REQUEST_BODY_TOO_LARGE Endpoints that can receive oversized body.
429 COMMON_429 SECURITY_RATE_LIMIT_EXCEEDED All endpoints behind rate limiting.
409 COMMON_409 IDEMPOTENCY_KEY_REUSED_WITH_DIFFERENT_PAYLOAD Write endpoints with idempotency semantics.
400 COMMON_400 IDEMPOTENCY_KEY_REQUIRED Write endpoints where idempotency key is required.

Entity matrix example: user

Endpoint HTTP status Class Code prefix Current examples
POST /api/v1/user 400 Mixed: COMMON + entity COMMON_* + USER_* IDEMPOTENCY_KEY_REQUIRED, USER_CREATE_ALREADY_EXISTS
POST /api/v1/user 422 Entity validation matrix USER_00x USER_001...USER_013
GET /api/v1/user/{system_user_id} 404 Entity business USER_* USER_NOT_FOUND (USER_404)
PUT /api/v1/user/{system_user_id} 422 Entity validation matrix USER_014…USER_024 Update body rules (e.g. USER_UPDATE_TIMEZONE_INVALID)
PATCH /api/v1/user/{system_user_id} 400 Entity business USER_102 USER_PATCH_BODY_EMPTY (no fields in body)
PATCH /api/v1/user/{system_user_id} 422 Entity validation matrix USER_014…USER_024 Same field rules as PUT when a field is present
GET /api/v1/user/{system_user_id} 401, 429 COMMON reusable COMMON_* Auth and rate-limit responses reused from shared pool

Router review checklist (status-first)

  1. List all response statuses declared in router responses={...}.
  2. Mark each status as COMMON or ENTITY.
  3. Ensure COMMON statuses come from app/openapi/responses.py.
  4. Ensure ENTITY statuses use entity-prefixed code space and mapped examples.
  5. Validate with tests and make verify.

Related governance docs

Page history

Date Change Author
Added Page history section (repository baseline). Ivan Boyarkin