Skip to content

No 2XX status codes without a body may hide errors #76

@davidlopezre

Description

@davidlopezre

The FusionAuth Go client, can hide errors if a response body is not received.

This issue can be replicated by providing a bad URL to the client constructor so that it always returns a 502 with no response body.

For example:

client := fusionauth.NewClient(nil, badUrlThatAlwaysReturnsEmpty502, apiKey)

// then, errors will be empty and err will be nil even though status code is 502
resp, errors, err := client.SearchEntitiesWithContext(ctx, req)

I think this is happening because on non 2XX response, the client intends to unmarshal the body into Errors while setting error to nil. This means, if there's nothing to unmarshal, both error and Errors end up being empty:

https://github.com/FusionAuth/go-client/blob/2d8a30ba49969c598f87ac82ab4d0745e4133deb/pkg/fusionauth/Client.go#L116C3-L116C13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions