Bug: __parse_headers need to handle KeyErrors #9

Closed
opened 2023-11-11 20:31:18 +00:00 by agatha · 0 comments
Owner
Traceback (most recent call last):
  File "/home/user/data/projects/gitmon/main.py", line 39, in <module>
    main()
  File "/home/user/data/projects/gitmon/main.py", line 30, in main
    events = api.get_events()
             ^^^^^^^^^^^^^^^^
  File "/home/user/data/projects/gitmon/gitmon/api.py", line 95, in get_events
    events = self.__get(endpoint, params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/data/projects/gitmon/gitmon/api.py", line 65, in __get
    self.__parse_headers(response.headers)
  File "/home/user/data/projects/gitmon/gitmon/api.py", line 75, in __parse_headers
    self.rate_reset = datetime.fromtimestamp(int(headers['x-ratelimit-reset']))
                                                 ~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/data/projects/gitmon/venv/lib/python3.11/site-packages/requests/structures.py", line 52, in __getitem__
    return self._store[key.lower()][1]
           ~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'x-ratelimit-reset'
``` Traceback (most recent call last): File "/home/user/data/projects/gitmon/main.py", line 39, in <module> main() File "/home/user/data/projects/gitmon/main.py", line 30, in main events = api.get_events() ^^^^^^^^^^^^^^^^ File "/home/user/data/projects/gitmon/gitmon/api.py", line 95, in get_events events = self.__get(endpoint, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/user/data/projects/gitmon/gitmon/api.py", line 65, in __get self.__parse_headers(response.headers) File "/home/user/data/projects/gitmon/gitmon/api.py", line 75, in __parse_headers self.rate_reset = datetime.fromtimestamp(int(headers['x-ratelimit-reset'])) ~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/home/user/data/projects/gitmon/venv/lib/python3.11/site-packages/requests/structures.py", line 52, in __getitem__ return self._store[key.lower()][1] ~~~~~~~~~~~^^^^^^^^^^^^^ KeyError: 'x-ratelimit-reset' ```
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: agatha/gitmon#9
No description provided.