mixpanel / mixpanel-utils

Other
85 stars 62 forks source link

_get_engage_page raises TypeError when request is rate limited #51

Open MaryFletcher opened 1 year ago

MaryFletcher commented 1 year ago

_get_engage_page raises "TypeError: the JSON object must be str, bytes or bytearray, not NoneType" when the request fails with a 429 rate limited response.

The call to self.request in _get_engage_page on line 1956 doesn't return a value for HTTP error codes below 500. (See the logic for handling HTTP errors in request.) The next line in _get_engage_page calls json.loads(response) where response is None and a TypeError is raised.

I'm hitting the following:

WARNING: The server couldn't fulfill the request.
WARNING: Error code: 429
WARNING: Reason: Too Many Requests
...
File "/var/task/mixpanel_api/__init__.py", line 1631, in _get_engage_page
data = json.loads(response)
File "/var/lang/lib/python3.9/json/__init__.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType