Skip to content

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

Open
@OliverJAsh

Description

@OliverJAsh

openapi-fetch may return an error of value undefined, when content length is 0 and response is not okay:

// handle empty content
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
return response.ok ? { data: undefined, response } : { error: undefined, response };
}

However, openapi-react-query does not propagate this error, because the error is only propagated when error is truthy, as per this code:

if (error) {
throw error;
}

To fix this, I believe this if (error) check should be if (!response.ok) and/or if ('error' in result).

We might also want to consider whether it makes sense for openapi-fetch to return undefined as an error, in the scenario mentioned above.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-react-queryRelevant to openapi-react-query

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions