Skip to content

Conversation

@usame-algan
Copy link
Contributor

What this solves

A 204 response doesn't contain a body so calling response.json() will throw. This is caught locally and we check if there is a content-length: 0 header to cover the case of a 204 response. If there is no such header we throw again. The issue is that by default, the CGW returns 204 responses without such a header as it is not enforced.

To solve this we are explicitely checking for a 204 status and don't call response.json() in that case.

@github-actions
Copy link

github-actions bot commented Feb 28, 2024

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action


try {
json = await resp.json()
json = resp.status === 204 ? {} : await resp.json()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here? I personally didn't know what 204 means and had to look it up.

@usame-algan usame-algan merged commit 66c90c0 into main Feb 28, 2024
@usame-algan usame-algan deleted the fix-204 branch February 28, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants