content-type parsing is performed even if a text
response type is explicitly requested, causing an unmanageable error
#553
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Just upgraded to
6.0.0
and immediately I'm facing a problem. The new behavior of unconditionally parsing the data based on content-type of the response is preventing me to override an invalidcontent-type
that is sent by a server.I've set the response type to
'text'
, to intentionally override and prevent any attempt at parsing the data by Gaxios, but that doesn't seem to work anymore in6.0.0
.After downgrading back to
5.1.3
I realized that in the previous version, even if I set the response type to'json'
, it would ignore the parsing error and provide the response as text instead. Here is the relevant method in the Gaxios code:In
getResponseData
, there is no handling of the case where the user explicitly specifies'text'
as response type. The new behavior, of having thecontent-type
unconditionally parsed, is now causing an attempt to parse the response as JSON even if that wasn't requested, and failing in an unrecoverable way when the parsing fails.I suggest that the function would be extended to consider when the user explicitly specifies the
text
response type:I also suggest that the new auto-parsing behavior would be modified to ignore JSON parsing errors, similarly to
getResponseData
:Please let me know if you would like a pull request for this.
The text was updated successfully, but these errors were encountered: