Skip to content

openapi-react-query resolves requests as success regardless of HTTP code if Content-Lenght is set to 0 #2463

@Roukanken47

Description

@Roukanken47

openapi-react-query version

0.5.0

Description

Due to optimization in openapi-fetch, it can return error responses in shape of {error: undefined, response}. React query handling code will ignore such errors, and will instead return a successful response.

Reproduction

Easy reproduction is to use a mutateAsync on an endpoint returning empty response with an error code.

try {
    await mutateAsync();             // ensure it returns 4xx or 5xx with Content-Lenght 0
    console.log("This will execute");
} catch {
    console.log("But this won't");
}

Expected result

Promise is not resolved, and catch code will execute.

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-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