{"record":{"id":"05726ce312a96d95","repo":"vercel/ai","slug":"failed-to-process-successful-response","errorCode":null,"errorMessage":"Failed to process successful response","messagePattern":"Failed to process successful response","errorType":"exception","errorClass":"APICallError","httpStatus":null,"severity":"error","filePath":"packages/provider-utils/src/get-from-api.ts","lineNumber":142,"sourceCode":"      }\n\n      throw errorInformation.value;\n    }\n\n    try {\n      return await successfulResponseHandler({\n        response,\n        url,\n        requestBodyValues: {},\n      });\n    } catch (error) {\n      if (error instanceof Error) {\n        if (isAbortError(error) || APICallError.isInstance(error)) {\n          throw error;\n        }\n      }\n\n      throw new APICallError({\n        message: 'Failed to process successful response',\n        cause: error,\n        statusCode: response.status,\n        url,\n        responseHeaders,\n        requestBodyValues: {},\n      });\n    }\n  } catch (error) {\n    throw handleFetchError({ error, url, requestBodyValues: {} });\n  }\n};\n","sourceCodeStart":124,"sourceCodeEnd":155,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/provider-utils/src/get-from-api.ts#L124-L155","documentation":"getFromApi received a successful (2xx) HTTP response, but an exception occurred while reading or processing the response body (e.g. JSON parsing or transformation). The library re-throws abort errors and APICallErrors unchanged, and wraps any other failure in an APICallError with this message, keeping the original error as `cause`.","triggerScenarios":"A fetch inside getFromApi returned status 2xx, then response.json()/body consumption threw a non-abort, non-APICallError exception — e.g. invalid JSON in a 200 response, or the body stream failing while being read.","commonSituations":"Misbehaving proxy or middleware returning 200 with an HTML/empty body; custom fetch implementations that break streaming; interrupted connections after headers were received; provider returning malformed JSON payloads on success.","solutions":["Inspect `error.cause` to identify the underlying body-processing failure","Verify the endpoint actually returns JSON with status 200 (curl the URL / check provider status page)","Check any custom `fetch` wrapper for interference with response body reading","Retry; if the 200-with-bad-body persists, capture url/status/headers and report to the provider package maintainers"],"exampleFix":"try {\n  await result;\n} catch (error) {\n  if (APICallError.isInstance(error) && error.message === 'Failed to process successful response') {\n    console.error('status was 200 but body processing failed:', error.cause);\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isFailedToProcessSuccessfulResponse(e: unknown): e is APICallError {\n  return APICallError.isInstance(e) && e.message === 'Failed to process successful response';\n}","tryCatchPattern":"try {\n  await getFromApi({ url, successfulResponseHandler: jsonResponseHandler });\n} catch (error) {\n  if (APICallError.isInstance(error) && error.statusCode === 200) {\n    console.error('200 but body processing failed:', error.cause);\n  }\n}","preventionTips":["Ensure custom fetch wrappers pass Response bodies through unmodified","Verify the endpoint returns valid JSON on success (curl/test before integrating)","Treat network flakiness with bounded retries"],"tags":["network","http","json","provider"],"backgroundTag":"api-response-parse-failed","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}