mvp-ai's picture
download
raw
11.7 kB
id,category,option,best_for,avoid_when,tradeoffs,tags,last_verified
BE066,Taxonomy,Structured Machine-Readable Error Codes,"Any API with more than a handful of endpoints, so clients can branch on `error.code` instead of parsing message strings","A single-endpoint internal script where nobody but the author ever reads the error","Clients build reliable error-handling logic against stable codes instead of fragile string matching on human-readable messages","error-codes|taxonomy|api-contract",2026-07-03
BE067,Taxonomy,Operational vs Programmer Error Distinction,"Deciding whether to fail gracefully (operational: bad input, network blip, expected downstream failure) vs. crash loudly (programmer: null reference, broken invariant)","Never skip this distinction — conflating the two either crashes on recoverable errors or silently limps along on real bugs","Operational errors should return a clean response; programmer errors should be logged loudly and often should crash the process so orchestration restarts it into a known-good state","error-taxonomy|reliability|node-best-practice",2026-07-03
BE068,Taxonomy,HTTP Status Code Mapping,"Picking 400 (malformed request) vs 422 (well-formed but semantically invalid) vs 409 (conflict) vs 429 (rate limited) vs 503 (temporarily unavailable) precisely rather than defaulting everything to 400 or 500","Internal RPC-style calls where the transport isn't really HTTP semantics-aware — a single error envelope may matter more than status code precision","Precise status codes let generic HTTP infrastructure (caches, retries, monitoring) behave correctly without reading the response body","http-status|rest|api-contract",2026-07-03
BE069,Taxonomy,Never Leak Stack Traces or Internals to the Client,"Every production API response, without exception — return a generic message plus a correlation id, log the detail server-side","Local development, where full error detail speeds up debugging — gate verbose errors behind an environment check, never behind a client-supplied flag","Prevents leaking implementation details (file paths, library versions, query fragments) that help an attacker; the correlation id still lets you find the real error in logs","security|error-leakage|production",2026-07-03
BE070,Taxonomy,User-Facing vs Internal Error Message Separation,"Any error a real user might see — translate internal exceptions into a message a non-technical person can act on ('please check your email format', not 'ValidationError at line 42')","Internal admin tools where the audience is engineers who benefit from the raw error","Keeps the client-facing surface friendly while still logging the full technical detail for debugging","ux|error-messages|user-facing",2026-07-03
BE071,Resilience,Retry with Exponential Backoff and Jitter,"Calls to flaky or rate-limited downstream services (third-party APIs, sometimes your own DB under load)","The failure is guaranteed to be permanent (e.g. 401 unauthorized, 404 not found) — retrying those just wastes time and obscures the real error","Backoff with jitter avoids a thundering herd of synchronized retries after an outage; must be paired with idempotency (see BE058) so retries can't double-apply a side effect","retry|backoff|resilience",2026-07-03
BE072,Resilience,Circuit Breaker for Downstream Calls,"A downstream dependency that's currently failing repeatedly — stop hammering it and fail fast instead, giving it room to recover","Low-traffic internal calls where a circuit breaker's operational complexity isn't justified by the failure volume","Fails fast once a threshold of recent failures is hit, protecting both your service (no threads/connections tied up waiting) and the struggling downstream service","circuit-breaker|resilience|microservices",2026-07-03
BE073,Resilience,Timeouts on Every Outbound Call,"Every HTTP/DB/queue call your server makes to another service — an unset timeout means one slow dependency can exhaust your entire request pool","Never skip this — there is no valid case for an unbounded outbound call in a request-serving process","A hung downstream call without a timeout eventually starves your server of connections/threads even though nothing 'crashed'","timeouts|reliability|resource-exhaustion",2026-07-03
BE074,Resilience,Dead Letter Queue for Failed Async Jobs,"Background job processing (queues, cron-triggered work) where a job that fails repeatedly needs to stop retrying and get flagged for a human","Synchronous request/response paths — DLQs are an async-job-queue concept, not a request-handling one","Prevents a single poison-pill job from retrying forever and consuming worker capacity; failed jobs land somewhere visible instead of silently vanishing","dlq|queues|async-jobs",2026-07-03
BE075,Resilience,Graceful Shutdown on SIGTERM,"Any long-running server process behind a deploy/orchestration system (Docker, Kubernetes, PM2) that sends SIGTERM before killing a container","Serverless/edge functions with no persistent process to shut down — this pattern doesn't apply there","Finishes in-flight requests and closes DB connections cleanly before exiting, avoiding dropped requests during every deploy","graceful-shutdown|deployment|reliability",2026-07-03
BE076,Observability,Structured JSON Logging,"Any production service — plain `console.log` strings are unqueryable once you have real log volume","A quick local prototype where you'll delete the logging before shipping anyway","Structured fields (level, message, requestId, userId, etc.) let your log aggregator filter/alert on real conditions instead of grepping strings","logging|observability|json-logs",2026-07-03
BE077,Observability,Request/Correlation ID Propagation,"Any system with more than one hop (frontend to backend, backend to downstream service) where you'll eventually need to trace one user's request across logs","A single-process script with no distributed calls to trace","Generate an id at the edge, propagate it through every downstream call and log line, and return it to the client in error responses so a support ticket can reference it","correlation-id|tracing|observability",2026-07-03
BE078,Observability,Centralized Error Monitoring (Sentry-style),"Production apps where you need to know about new error types before a user reports them","Local development only — send monitoring events from staging/production, not from every developer's laptop","Aggregates and deduplicates errors across all instances with stack traces and context, closing the loop that plain logs alone leave open (nobody watches logs in real time)","error-monitoring|sentry|alerting",2026-07-03
BE079,Observability,"Alert on Error Rate, Not Individual Errors","Setting up on-call alerting — page a human when the error *rate* crosses a threshold, not on every single occurrence","A truly critical, rare event (e.g. payment webhook signature failure) may warrant an alert on first occurrence — treat those as an explicit exception","Rate-based alerting avoids paging fatigue from normal background noise while still catching real regressions promptly","alerting|on-call|error-rate",2026-07-03
BE080,Validation,Validate at the Boundary (Zod / Pydantic / class-validator),"Every external input: request bodies, query params, env vars, webhook payloads — validate before any business logic touches the data","Never skip this at a true trust boundary — internal function calls within your own already-validated code don't need re-validation at every layer","Push invalid-shape errors to the edge of the system with a clear, consistent error instead of a confusing failure three layers deep in business logic","validation|zod|pydantic|boundary",2026-07-03
BE081,Validation,Fail Fast on Missing/Invalid Config at Startup,"Required environment variables (DB URL, API keys, secrets) — check they exist and are well-formed before the server starts accepting traffic","A genuinely optional config value with a safe default — those shouldn't fail startup","Crashing immediately on bad config is far easier to diagnose than a mysterious runtime failure hours later when that code path finally executes","config-validation|startup|fail-fast",2026-07-03
BE082,Response Shape,Consistent Error Envelope Across All Endpoints,"Pairing with BE059 — every error response uses the same shape (`code`, `message`, `requestId`, optional `details`) regardless of which endpoint or module produced it","A deliberately heterogeneous API where different sub-APIs have genuinely different consumers/contracts — document the divergence explicitly if so","One error-parsing code path on the client instead of one per endpoint; centralize this in the framework's global error-handling middleware, not per-route try/catch","error-envelope|consistency|api-contract",2026-07-03
BE083,Stack-Specific,Next.js — error.tsx Boundaries plus Route Handler try/catch,"Next.js App Router apps: use `error.tsx` for render-time errors and explicit try/catch inside Route Handlers for API errors, since they're separate error surfaces","Pages Router legacy code — use `_error.js`/`getInitialProps` error handling conventions instead","App Router's error boundaries don't automatically catch Route Handler errors — both need to be handled explicitly or API errors leak as unhandled 500s","nextjs|error-boundary|route-handlers",2026-07-03
BE084,Stack-Specific,Express/Nest.js — Centralized Error-Handling Middleware,"Express: a single error-handling middleware (4-arg signature) as the last app.use(); Nest.js: a global Exception Filter","Per-route try/catch scattered everywhere instead — harder to guarantee every route produces a consistent error envelope","Guarantees every unhandled error in any route passes through one place that maps it to the standard envelope (BE082) and logs it consistently","express|nestjs|middleware|exception-filter",2026-07-03
BE085,Stack-Specific,FastAPI — Exception Handlers plus Pydantic ValidationError Formatting,"FastAPI apps: register `@app.exception_handler()` for domain exceptions and customize the default 422 response shape from Pydantic validation errors to match your error envelope","A tiny script-style FastAPI app with no real client depending on a stable error shape","FastAPI's default validation error format is verbose and Pydantic-specific by default — reshape it once, centrally, to match BE082 rather than letting every client parse FastAPI's native format","fastapi|pydantic|exception-handlers",2026-07-03
BE086,Stack-Specific,Django REST Framework — Custom exception_handler,"DRF apps: override DRF's `EXCEPTION_HANDLER` setting to reshape both DRF's default error format and your own domain exceptions into one consistent envelope","Server-rendered Django views without DRF — use Django's own `handler404`/`handler500` template-based error pages instead","DRF's default error format differs from a hand-rolled envelope; centralizing this once avoids every viewset re-inventing error formatting","django|drf|exception-handler",2026-07-03
BE087,Stack-Specific,Supabase/Postgres — Map DB Error Codes to Friendly Messages,"Any code path that inserts/updates against Supabase/Postgres directly — catch `unique_violation` (23505), `foreign_key_violation` (23503), `check_violation` (23514) and map them to specific, friendly errors instead of a generic 500","Reading data only, with no writes that could hit a constraint","Postgres error codes are stable and documented — mapping the common ones (uniqueness, FK, check constraints) turns a raw DB error into an actionable client message ('that email is already taken') instead of a leaked 500","supabase|postgres|error-codes|constraints",2026-07-03

Xet Storage Details

Size:
11.7 kB
·
Xet hash:
2dedf0c8c885e8b6e65cb2a156027ddc3e465dd449f3de3c5613f3d3646ef7e0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.