Skip to content

SDK Fails with "SdkError: Failed to parse JSON response" on non-200 responses #204

@ohana54

Description

@ohana54

Hi,

We noticed that sometimes the service returns 500/502 errors and the response body is html.
The code doesn't check the status code and tries to parse the body as json, which fails with the error "SdkError: Failed to parse JSON response".

Context:

const response = await this.fetch(url, {
method: 'GET',
headers,
})
const jsonResponse = await copyResponseJson(response)

It would be nice to handle these cases so we can get a meaningful and correct error back.
I'll be happy to submit a PR if needed.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions