shopify-api-js
shopify-api-js copied to clipboard
Error handler swallows actual error message in HTTP Client
Issue summary
I was trying to integrate with the rest admin billing API and I noticed my error message coming back from the http client looks like:
Error adding subscription plan: Received an error response (400 Bad Request) from Shopify: [object Object]. If you report this error, please include this id: a638e060-1a08-4814-b879-5ff1d1984840
The [object Object] bit in particular shows the library code not correctly formatting the error response and thus swallowing it so I can't see the actual error.
Expected behavior
What do you think should happen?
This line (linked below) is overly simplistic and expects string concatenation to work in an array of error message (except sometimes these are not all strings). It should handle objects, OR it would be nice to expose the raw response body up the caller when the error is thrown:
https://github.com/Shopify/shopify-node-api/blob/main/src/clients/http_client/http_client.ts#L236
Actual behavior
What actually happens? -> [object Object]
Steps to reproduce the problem
- Call the REST billing API with a bad input data (e.g. don't include the name)
- See
[object Object]
Reduced test case
The best way to get your bug fixed is to provide a reduced test case.
When I use Axios and make my own client I can see the full message:
{
errors: {
recurring_application_charge: 'Required parameter missing or invalid'
}
}
Checklist
- [x] I have described this issue in a way that is actionable (if possible)
Hey @a-r-d, thanks for the detailed report. Which version of the library are you running? I ask because we've made some improvements to that error message and released it with v1.4.3, so you might be able to fix your issue by upgrading your library.
It's also worth noting that v2.0.0 is out, but if you want to avoid handling the breaking changes (see the CHANGELOG for them) you can stick with v1 for now.
@paulomarg I was using 1.4.1 it looks like. I am in the process of upgrading to 2.0.0 though right now, so I will try to follow up on this in a day or two if I still encounter this issue.
One thing about 2.0 is there were a lot of breaking changes to the webhooks code so I'm still kinda working through that. I like the improvements to the Auth code though, I started using that directly instead of the koa middleware wrapper. Unrelated of course!
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.
We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines
Thank you!