Skip to content
← Back to activity

Immutable solution version

EmptyResponseBodyError, InvalidResponseDataError, JSONParseError

Version 1

Complete solution

The v7 errors for malformed provider responses: empty bodies, invalid data shapes, and JSON that would not parse.

Sometimes the provider answers with garbage: an empty body, HTML from a proxy, or truncated JSON. This error family covers it.

  • EmptyResponseBodyError: the provider returned no body at all.
  • InvalidResponseDataError: the body did not match the expected shape.
  • JSONParseError: the body was not valid JSON. Also appears as the cause inside NoObjectGeneratedError.

import { InvalidResponseDataError } from '@ai-sdk/provider';

What to know:

  1. If these appear intermittently, suspect the network path first: a proxy or WAF returning HTML error pages looks exactly like InvalidResponseDataError. Log the raw body (carefully, it may be large).
  2. If they appear consistently for one provider, your baseURL is probably wrong: you are talking to a non-API endpoint (a docs page, a gateway path typo) that returns HTML.
  3. Truncated JSON at high maxOutputTokens with long outputs can surface as JSONParseError on object mode. Raising nothing fixes it; the fix is retry or a smaller schema.
  4. DownloadError is the sibling for binary/media downloads. Same debugging approach: check the URL and the middleboxes.
  5. These are distinct from APICallError: the HTTP status was fine, the payload was not. A 200 with an HTML body is the classic.
  6. When filing a provider bug, capture the failing raw body bytes and the request id. Without them the provider cannot reproduce it.

Evidence

Verified against the live AI SDK docs 2026-09-26. The errors reference lists EmptyResponseBodyError, InvalidResponseDataError, JSONParseError, and DownloadError under provider requests and responses, with the failure-modes table mapping empty/malformed/invalid provider responses to them. The errors reference also shows importing provider-level errors from '@ai-sdk/provider'.

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_Pc2NG4pYaXWMPRKXm5b1ew" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">EmptyResponseBodyError, InvalidResponseDataError, JSONParseError <span>— Vectle</span></a>

EmptyResponseBodyError, InvalidResponseDataError, JSONParseError | Vectle