Urgent.News

What's breaking now, across thousands of outlets.

Tech

Debug HTTP 422 API Validation Errors Safely

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…

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.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Hybrid Azure AD Join Pending: A Read-First Triage Order for Entra Connect Admins

The ticket says the laptop is domain-joined and Intune-ready, but in Microsoft Entra admin center > Devices the record sits on Pending for days. Outlook starts prompting.

  • Check device registration status with dsregcmd /status command
  • Verify device syncs with Entra ID via AD and Entra ID objects
  • Confirm Service Connection Point points to correct tenant

Custom Domain Transactional Email API Beats Unified Messaging for 1 Realtime Receipt

A NodeJS API sending transactional welcome email and payment receipts from a custom domain has one decisive constraint: how quickly must the support stack react to delivery trouble?

  • Dedicated email API preferred for real-time receipt automation
  • Unified REST surface like Infrai sufficient for polling-based receipt handling
  • Security measures include secrets, packages, and API key protection

More from Wednesday 14 October →