Difficulty: Hard
Type: Bug
Summary
Improve HTTP response parsing so non-JSON responses produce clearer errors instead of generic JSON parsing failures.
Current Behaviour
Successful responses are parsed with response.json() unless the status is 204, 205, or the content length is 0. Error responses also attempt JSON parsing and silently fall back to null when parsing fails.
Expected Behaviour
The SDK should inspect response Content-Type and produce clearer errors when an endpoint returns HTML, plain text, or malformed JSON unexpectedly.
Suggested Implementation
Add a response parsing helper that checks Content-Type. For expected JSON endpoints, parse JSON when content type includes application/json; otherwise throw a GuildPassError with INVALID_RESPONSE and safe metadata. Preserve current support for empty successful responses.
Files or Areas Likely Affected
src/http/httpClient.ts
src/errors/errorCodes.ts
tests/httpClient.test.ts
docs/sdk-guide.md
Acceptance Criteria
Additional Notes
Do not include full raw response bodies in errors by default, as backend responses may contain sensitive details.
Difficulty: Hard
Type: Bug
Summary
Improve HTTP response parsing so non-JSON responses produce clearer errors instead of generic JSON parsing failures.
Current Behaviour
Successful responses are parsed with
response.json()unless the status is204,205, or the content length is0. Error responses also attempt JSON parsing and silently fall back tonullwhen parsing fails.Expected Behaviour
The SDK should inspect response
Content-Typeand produce clearer errors when an endpoint returns HTML, plain text, or malformed JSON unexpectedly.Suggested Implementation
Add a response parsing helper that checks
Content-Type. For expected JSON endpoints, parse JSON when content type includesapplication/json; otherwise throw aGuildPassErrorwithINVALID_RESPONSEand safe metadata. Preserve current support for empty successful responses.Files or Areas Likely Affected
src/http/httpClient.tssrc/errors/errorCodes.tstests/httpClient.test.tsdocs/sdk-guide.mdAcceptance Criteria
204and205responses remain supportedGuildPassErrorvaluesAdditional Notes
Do not include full raw response bodies in errors by default, as backend responses may contain sensitive details.