Nicer error message for invalid token
- Dominant language
- Python
- Stars
- 826
- Forks
- 79
- PR merge metrics
- No merged PRs in 30d
Description
From the profiler server we get -
```
[2023-02-08 07:19:07,476] ERROR: gprofiler: Server error: Invalid API key
```
and the agent exits.
For the API server of glogger, we get this:
```
2023-02-08 07:19:08,434 - ERROR - Error posting to server
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/glogger/sender.py", line 122, in send
batch = self._send_once()
File "/usr/local/lib/python3.8/dist-packages/glogger/sender.py", line 153, in _send_once
self._send_once_to_server(data)
File "/usr/local/lib/python3.8/dist-packages/glogger/sender.py", line 174, in _send_once_to_server
response.raise_for_status()
File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 960, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.granulate.io/api/v1/logs
2023-02-08 07:19:08,434 - ERROR - Error posting to server
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/glogger/sender.py", line 122, in send
batch = self._send_once()
File "/usr/local/lib/python3.8/dist-packages/glogger/sender.py", line 153, in _send_once
self._send_once_to_server(data)
File "/usr/local/lib/python3.8/dist-packages/glogger/sender.py", line 174, in _send_once_to_server
response.raise_for_status()
File "/usr/local/lib/python3.8/dist-packages/requests/models.py", line 960, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.granulate.io/api/v1/logs
```
This clutters the log and hides the simpler error message. We should catch the error and replace with a nicer print. This requires changing granulate-utils' `Sender` - catch the 401 error and log a nicer message.
At the same time we can change the "server error: invalid API key" log to be CRITICAL.
Contributor guide
Assessment
This issue has not been assessed yet.