altimate-code icon indicating copy to clipboard operation
altimate-code copied to clipboard

SDK client crashes with a raw JSON parse error on non-JSON (HTML) API responses

Open ralphstodomingo opened this issue 3 months ago • 1 comments

Describe the bug

When a proxy / gateway / CDN returns an HTTP 200 with an HTML body (an error or interstitial page) instead of JSON, the generated SDK client crashes with a raw JSON Parse error: Unrecognized token '<'.

parseAs falls back to "json" whenever Content-Type is missing or unrecognized, so a non-JSON body reaches JSON.parse unguarded on the success path (the error-response path is already guarded). Surfaces to users as chat sendMessageError with an unactionable parse error (~11 machines / 7d in telemetry).

Expected behavior

An actionable error naming the received content-type and HTTP status (e.g. "Expected a JSON response but received text/html (HTTP 200) — usually a proxy or gateway error page"), instead of a raw parse crash.

To Reproduce

  1. Point the CLI's backend at an endpoint returning 200 + an HTML body (with a JSON or missing content-type).
  2. Send a chat message.
  3. Observe SyntaxError: JSON Parse error: Unrecognized token '<' instead of a useful error.

ralphstodomingo avatar Aug 19 '26 03:08 ralphstodomingo

Resolved in v0.11.0.

sahrizvi avatar Sep 09 '26 17:09 sahrizvi