Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Opaque error when the client exceeds the API limit. #24

Closed
sakoht opened this issue Apr 9, 2021 · 2 comments · Fixed by #26
Closed

Opaque error when the client exceeds the API limit. #24

sakoht opened this issue Apr 9, 2021 · 2 comments · Fixed by #26

Comments

@sakoht
Copy link

sakoht commented Apr 9, 2021

Currently when the client hits the request limit, the HTTP 403 with the response body <h1>Developer Over Rate</h1>.

But the user gets an opaque message:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/egnyte/resources.py", line 204, in list
    return self._get()
  File "/usr/local/lib/python3.7/site-packages/egnyte/resources.py", line 53, in _get
    json = exc.default.check_json_response(self._client.GET(self._url))
  File "/usr/local/lib/python3.7/site-packages/egnyte/exc.py", line 183, in check_json_response
    r = self.check_response(response, *ok_statuses)
  File "/usr/local/lib/python3.7/site-packages/egnyte/exc.py", line 168, in check_response
    raise error_type(*errors)
egnyte.exc.InsufficientPermissions: <exception str() failed>

The errors passed into the error constructor include the essential information, but something is missing when the error prints.

[{'url': 'https://celsiustx.egnyte.com/pubapi/v1/fs/Shared/Celsius%20Partners'}, {'http response': '<h1>Developer Over Rate</h1>'}, {'http status': 403}, {'headers': {'X-Mashery-Responder': 'avl-mashery-4-4-3-slave01', 'X-AccessToken-QPS-Allotted': '2', 'X-AccessToken-QPS-Current': '1', 'X-AccessToken-Quota-Allotted': '1000', 'X-AccessToken-Quota-Current': '1001', 'X-Quota-Reset': 'Saturday, April 10, 2021 12:00:00 AM GMT', 'Retry-After': '37342', 'X-Error-Detail-Header': 'Account Over Rate Limit', 'X-Mashery-Error-Code': 'ERR_403_DEVELOPER_OVER_RATE', 'Content-Type': 'text/xml', 'Date': 'Fri, 09 Apr 2021 13:37:39 GMT', 'Content-Length': '28', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'X-Egnyte-Request-Id': '*********'}}]
@sakoht
Copy link
Author

sakoht commented Aug 4, 2021

I believe the error is that for item in self should be self.args:

    def __str__(self):
        """Pretty-printed version. Use repr for bare vesion instead"""
        contents = []
        for item in self:  # <===== should be self.args?
            if isinstance(item, dict):
                contents.append("{%s}" % ", ".join(sorted(["%s: '%s'" % (k, v) for (k, v) in item.items()])))
            else:
                contents.append(str(item))
        return "<%s: %s>" % (self.__class__.__name__, ", ".join(contents))

This is for the latest production release 0.5.3, which was released in 2017. Looks like master is still changing.

I'll make a PR for this if you are up for fixing the production release that is what people get when they install with pip?

@gdubicki
Copy link
Contributor

Thanks @sakoht , I applied your suggestion in #26 and it seems to help. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants