{
  "id": 14355574,
  "title": "Debug HTTP 422 API Validation Errors Safely",
  "url": "https://urgent.news/2026/10/14/debug-http-422-api-validation-errors-safely",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-14T03:03:21.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/raylabs/debug-http-422-api-validation-errors-safely-2g48"
  },
  "original_language": "en",
  "account": "When an API returns an HTTP 422 response, client integrations often overlook field-level details or flood logs with the entire response body. To handle these errors safely, you can use an asynchronous function called \"readAndFormat422\" that takes a response object and returns a promise string. The function reads the response text, attempts to parse it as JSON, and extracts the first ten error fields if successful. If parsing fails, it returns the first 200 characters of the raw response. HTTP 422 status codes indicate that the server understands the request content type and syntax, but cannot process the contained instructions. This status code requires your client to handle varied error-body schemas safely without assuming a universal structure. Avoid the anti-patterns of only catching non-2xx responses or logging raw response text, as these can lead to loss of valuable context and sensitive data leakage. Instead, bound character lengths and field counts, sanitize sensitive patterns before persistence, and confirm that 422 responses do not trigger infinite retry loops.",
  "summary": "When an API returns an HTTP 422 response, client integrations often discard field-level details or dump entire response bodies into logs. Quick solution: async function readAndFormat422 ( response : Response ): Promise < string > { const raw = await response . text (); try { const body = JSON . parse ( raw ); const errors = body . errors ; if ( errors && typeof errors === \" object \" ) { return…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}