Skip to content

Handle response objects of instance String for API errors - #509

Merged
AaronDDM merged 5 commits into
mainfrom
CUST-3714
Jan 21, 2025
Merged

AaronDDM merged 5 commits into
mainfrom
CUST-3714

Conversation

@kraju3

@kraju3 kraju3 commented Jan 10, 2025

Copy link
Copy Markdown
Contributor

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.

@nickbair-nylas nickbair-nylas left a comment

Copy link
Copy Markdown
Contributor

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?

@AaronDDM AaronDDM left a comment

Copy link
Copy Markdown
Contributor

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

kraju3 commented Jan 13, 2025

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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

kraju3 commented Jan 14, 2025

Copy link
Copy Markdown
Contributor Author

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
@AaronDDM AaronDDM mentioned this pull request Jan 23, 2025

This branch was successfully deployed

1 active deployment
sdk-reference — 9090b646 Deployed Jan 21, 2025 by kraju3
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