github graffle-js/graffle graphql-request@7.3.3

4 hours ago

Bug Fixes

  • Non-JSON Error Response Handling: Fixed regression in 7.3.2 where servers returning HTTP 4xx/5xx status codes with non-JSON response bodies (HTML, plain text) would throw an unhelpful error: "Invalid execution result: result is not object or array" (#1459, closes #1458)
    • Added safe JSON parsing fallback for responses without proper Content-Type headers
    • Returns descriptive error messages with response body preview for non-JSON responses
    • Handles common production scenarios: load balancer errors (502/503 HTML pages), CDN errors, WAF/firewall responses, misconfigured servers
    • Maintains backward compatibility for servers that omit Content-Type but return valid JSON
    • Added comprehensive test coverage for HTML, plain text, and missing Content-Type scenarios

What Changed

Version 7.3.2 introduced a bug where the ELSE branch in parseResultFromResponse would pass raw strings (HTML, plain text) to a parser expecting objects/arrays. This only surfaced when:

  1. Server returns 4xx/5xx status code
  2. Content-Type header is missing or non-JSON (e.g., text/html, text/plain)
  3. Response body is not valid JSON

This is now fixed with graceful error handling and clear error messages.

Don't miss a new graffle release

NewReleases is sending notifications on new releases.