Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where JSON error response might get treated as non-JSON error response #1407

Merged
merged 9 commits into from
Jan 8, 2025

Conversation

Mtn-View
Copy link
Contributor

@Mtn-View Mtn-View commented Jan 7, 2025

Fixes # N/A

To help everyone out, please make sure your PR does the following:

  • Update the first line to point to the ticket that this PR fixes
  • Add a message that clearly describes the fix
  • If applicable, add a test that would fail without this fix
  • Make sure the unit and integration tests pass locally with pnpm run tests and cd integration && pnpm run tests
  • Includes a changeset if your fix affects the user with pnpm changeset

This PR fixes a bug from #1404 where valid content-types would be treated as invalid because it checked that the content-type was strictly equal to one of the valid values. However, the content-type header can have other stuff in it after the content type, (e.g. application/json; charset=utf-8) so just check that it starts with the right thing instead of checking equality.

Without this, if the server returns an NGINX error page, `defaultFetch` will still attempt to parse the response as JSON, which will throw a syntax error, which is harder to understand than something like `502: Bad Gateway`
The `content-type` header can have `charset` or `boundary` in it as well, so just make sure it starts with one of the valid content types instead of checking strict equality.
Copy link

changeset-bot bot commented Jan 7, 2025

🦋 Changeset detected

Latest commit: 9892ef3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
houdini Patch
houdini-adapter-auto Patch
houdini-adapter-cloudflare Patch
houdini-adapter-node Patch
houdini-adapter-static Patch
houdini-react Patch
houdini-svelte Patch
houdini-plugin-svelte-global-stores Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for houdinigraphql canceled.

Name Link
🔨 Latest commit 9892ef3
🔍 Latest deploy log https://app.netlify.com/sites/houdinigraphql/deploys/677d65e7b6b9600008bb2f46

Copy link

netlify bot commented Jan 7, 2025

Deploy Preview for houdini-docs-next canceled.

Name Link
🔨 Latest commit 9892ef3
🔍 Latest deploy log https://app.netlify.com/sites/houdini-docs-next/deploys/677d65e7ba05730008536bed

Accidentally got included from the last PR I made, woops
@Mtn-View Mtn-View requested a review from SeppahBaws January 7, 2025 17:51
@SeppahBaws SeppahBaws merged commit d7b30f0 into HoudiniGraphql:main Jan 8, 2025
15 checks passed
@github-actions github-actions bot mentioned this pull request Jan 8, 2025
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.

2 participants