Skip to content

fix(openapi-react-query): propagate undefined errors from openapi-fetch#2813

Open
Will-hxw wants to merge 2 commits into
openapi-ts:mainfrom
Will-hxw:fix/propagate-undefined-errors
Open

fix(openapi-react-query): propagate undefined errors from openapi-fetch#2813
Will-hxw wants to merge 2 commits into
openapi-ts:mainfrom
Will-hxw:fix/propagate-undefined-errors

Conversation

@Will-hxw
Copy link
Copy Markdown

Summary

  • Use !response.ok instead of error truthiness check in queryFn, useInfiniteQuery, and useMutation
  • Properly handle cases where openapi-fetch returns error: undefined for non-OK responses with empty bodies

Why

When openapi-fetch receives a non-OK response (e.g., 500) with an empty body, it returns { error: undefined, response }. The previous if (error) check was falsy for undefined, causing the error to be silently swallowed. This fix checks !response.ok instead, ensuring errors are always propagated.

Validation

  • Ran pnpm test --filter openapi-react-query — all 38 tests pass (37 existing + 1 new)
  • Added test case for 500 response with empty body

Related

Closes #2070

Use  instead of  truthiness check to properly
handle cases where openapi-fetch returns  for
non-OK responses with empty bodies.

Closes openapi-ts#2070
@Will-hxw Will-hxw requested a review from a team as a code owner May 17, 2026 11:35
@Will-hxw Will-hxw requested a review from duncanbeevers May 17, 2026 11:35
@netlify
Copy link
Copy Markdown

netlify Bot commented May 17, 2026

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 19e40ed

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

🦋 Changeset detected

Latest commit: 19e40ed

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

This PR includes changesets to release 1 package
Name Type
openapi-react-query 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

@Will-hxw
Copy link
Copy Markdown
Author

No description provided.

@Will-hxw
Copy link
Copy Markdown
Author

Hi!@duncanbeevers,sorry to bother you. This PR has been open for a while, so I wanted to kindly check whether you might have time to review it or let me know if any changes are needed.I’m happy to make adjustments if required. Thanks!

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.

openapi-react-query does not propagate undefined errors from openapi-fetch

1 participant