Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle error response codes on features repository initialization #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

micpalmia
Copy link

At the moment, HTTP status codes different than 200 are completely ignored. This leads to confusing error messages that don't help clients debug the issue quickly. Adding a check for the return status code helps ensure a more meaningful error message can be returned.

Ideally, the body of the response should be logged rather than provided in the exception message. In the absence of a logging framework in the library however, I think emitting the body in the message can help debugging.

Happy to adapt as needed if you have any feedback.

…zation

At the moment, HTTP status codes different than 200 are completely ignored.
This leads to confusing error messages that don't help clients debug the issue quickly.
Adding a check for the return status code helps ensure a more meaningful error message can be returned.

Ideally, the body of the response should be logged rather than provided in the exception message.
In the absence of a logging framework in the library, I think emitting the body in the message can help debugging.
Copy link
Contributor

@tinahollygb tinahollygb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see inline comment re: regression.

FeatureFetchException.FeatureFetchErrorCode.NO_RESPONSE_ERROR
);
}
if (response.code() != 200) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @micpalmia thanks for your contribution. Unfortunately this approach will be quite fragile and will introduce a regression. In some cases, the API returns 304 with the content, and in those cases, this will break the SDK.

image

https://cdn.growthbook.io/api/features/java_NsrWldWd5bxQJZftGsWKl7R2yD2LtAK8C8EUYh9L8

Please update your error check to include only error-related status codes.

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.

None yet

2 participants