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

Handle response objects of instance String for API errors #509

Merged
merged 5 commits into from
Jan 21, 2025
Merged

Conversation

kraju3
Copy link
Contributor

@kraju3 kraju3 commented Jan 10, 2025

Description

Due to unexpected errors such as Bad Gateway, the response object is of Instance string, while trying to fetch the provider_error we return a Ruby error of
undefined method fetch' for "Bad Gateway":String`

This PR addresses the type before parsing the provider_error property

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

Copy link
Contributor

@nickbair-nylas nickbair-nylas left a comment

Choose a reason for hiding this comment

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

LGTM, worth adding a test case for this?

Copy link
Contributor

@AaronDDM AaronDDM left a comment

Choose a reason for hiding this comment

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

Thanks Kiran! Could you add a test, ideally for a legitimate error that we're experiencing.

@kraju3
Copy link
Contributor Author

kraju3 commented Jan 13, 2025

@AaronDDM @nickbair-nylas I think there are some tests regarding this in http_client.spec file? Would you be able to sanity check if that is doing the same?

@nickbair-nylas
Copy link
Contributor

@kraju3 the only test I see for #throw_error uses an error object (here). I think you could just copy this test and pass error as a string.

@kraju3
Copy link
Contributor Author

kraju3 commented Jan 14, 2025

Added a test for this change.

One of the github action is failing. I am not sure if it's related to this:
actions/runner-images#10636

@AaronDDM AaronDDM merged commit d8bdd1c into main Jan 21, 2025
6 checks passed
@AaronDDM AaronDDM mentioned this pull request Jan 23, 2025
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.

undefined method `fetch' for an instance of String: nylas/handler/http_client.rb in throw_error
3 participants