Skip to content

fix(openapi-react-query): propagate undefined errors from empty-body non-OK responses#2822

Open
EduardF1 wants to merge 2 commits into
openapi-ts:mainfrom
EduardF1:fix/propagate-undefined-errors-openapi-react-query
Open

fix(openapi-react-query): propagate undefined errors from empty-body non-OK responses#2822
EduardF1 wants to merge 2 commits into
openapi-ts:mainfrom
EduardF1:fix/propagate-undefined-errors-openapi-react-query

Conversation

@EduardF1
Copy link
Copy Markdown

Closes #2070.

What changed and why

  • update queryFn, useInfiniteQuery's queryFn, and mutationFn to throw when error !== undefined || !response.ok
  • destructure response anywhere it was missing so the non-OK HTTP status is available
  • add regression tests covering empty-body non-OK responses for query, mutation, and infinite query paths

Scenario fixed

When openapi-fetch returns { data: undefined, error: undefined, response } for a non-OK response with an empty body (for example, a 4xx/5xx response with Content-Length: 0), the previous if (error) check treated the result as successful and swallowed the failure. This change propagates those undefined errors correctly by also checking response.ok.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@EduardF1 EduardF1 requested a review from a team as a code owner May 30, 2026 00:06
@EduardF1 EduardF1 requested a review from duncanbeevers May 30, 2026 00:06
@netlify
Copy link
Copy Markdown

netlify Bot commented May 30, 2026

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit bdf4abf

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 30, 2026

🦋 Changeset detected

Latest commit: bdf4abf

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

@EduardF1
Copy link
Copy Markdown
Author

Thanks for the changeset reminder. This change should ship as a patch for openapi-react-query, so I will add a changeset for that package to keep the release metadata accurate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@EduardF1
Copy link
Copy Markdown
Author

Added the missing changeset for \openapi-react-query\ and pushed it in bdf4abf.

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