fix(sdk): handle empty JSON response bodies gracefully #7888
+67
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7889
Fixes #7715
Summary
client.gen.ts:167when server returns empty response bodyRoot Cause
Two issues causing the JSON parsing error:
/packages/console/app/src/routes/zen/v1/models.tsreturnedstatus: 200with null bodystatus: 204orContent-Length: "0", but didn't handle empty body with 200 status and no Content-Length headerChanges
Server (
packages/console/app/src/routes/zen/v1/models.ts)status: 200→status: 204(proper "No Content" status)SDK Client (both v1 and v2
client.gen.ts)Comparison with #7618
{}gracefullyThis PR prevents the crash entirely AND provides good error messages for actual malformed JSON.
Note
These files are auto-generated by
@hey-api/openapi-ts. This fix will need to be reapplied after regeneration, or ideally contributed upstream to@hey-api/client-fetch.