SatelCreative / spylib

A library to facilitate interfacing with Shopify's API
https://satelcreative.github.io/spylib
MIT License
3 stars 2 forks source link

🐛 Shopify error handling #211

Closed lishanl closed 8 months ago

lishanl commented 9 months ago

When Shopify GQL API returns 503 Service Unavailable, the content of the response is not JSON.

The error being raise from AprilAire is

  raise JSONDecodeError("Expecting value", s, err.value) from None
          │                                  └ '<!--\n  The source of truth for this generic error page is https://github.com/Shopify/error-pages.\n  Please do not edit thi...
          └ <class 'json.decoder.JSONDecodeError'>

Add retry to intermittent errors for 500 and 503 error codes Add a try block for the json parsing to throw a more informative error for non 200 returns

lishanl commented 8 months ago

Wait, so you are handling this in the GraphQL but what about Rest?

rest has a broader retry covereage.

https://github.com/SatelCreative/spylib/blob/73815ff5c06ecba5dc0e6bfb88085a4294bbd1b6/spylib/exceptions.py#L62-L67 https://github.com/SatelCreative/spylib/blob/73815ff5c06ecba5dc0e6bfb88085a4294bbd1b6/spylib/admin_api.py#L125-L131 https://github.com/SatelCreative/spylib/blob/73815ff5c06ecba5dc0e6bfb88085a4294bbd1b6/spylib/admin_api.py#L154-L156

https://github.com/SatelCreative/spylib/blob/73815ff5c06ecba5dc0e6bfb88085a4294bbd1b6/spylib/admin_api.py#L119-L121