You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a request comes back with a status of ok but the response body is empty or not json, an error is logged.
This is deceiving because we have APIs that don't return a body - only a 200 or 201.
Example:
ibl_local_lms | 2023-06-08 17:00:13,174 INFO 7 [ibl_request_router.views] [user 5] [ip 69.129.255.173] views.py:51 - Response core/users/platforms/: 201
ibl_local_lms | 2023-06-08 17:00:13,175 ERROR 7 [ibl_request_router.views] [user 5] [ip 69.129.255.173] views.py:58 - Non-JSON response core/users/platforms/: 201
ibl_local_lms | Traceback (most recent call last):
ibl_local_lms | File "/openedx/venv/lib/python3.8/site-packages/requests/models.py", line 971, in json
ibl_local_lms | return complexjson.loads(self.text, **kwargs)
ibl_local_lms | File "/openedx/venv/lib/python3.8/site-packages/simplejson/__init__.py", line 525, in loads
ibl_local_lms | return _default_decoder.decode(s)
ibl_local_lms | File "/openedx/venv/lib/python3.8/site-packages/simplejson/decoder.py", line 370, in decode
ibl_local_lms | obj, end = self.raw_decode(s)
ibl_local_lms | File "/openedx/venv/lib/python3.8/site-packages/simplejson/decoder.py", line 400, in raw_decode
ibl_local_lms | return self.scan_once(s, idx=_w(s, idx).end())
ibl_local_lms | simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ibl_local_lms |
ibl_local_lms | During handling of the above exception, another exception occurred:
ibl_local_lms |
ibl_local_lms | Traceback (most recent call last):
ibl_local_lms | File "/openedx/requirements/ibl-edx-request-router-app-0.2.5/src/ibl_request_router/views.py", line 53, in manager_proxy_view
ibl_local_lms | response.json(), status=response.status_code
ibl_local_lms | File "/openedx/venv/lib/python3.8/site-packages/requests/models.py", line 975, in json
ibl_local_lms | raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
ibl_local_lms | requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
We've already logged the response as text, so there's no reason to log that the response wasn't json, I don't think. At the very least we should remove the exc_info=True from the log and it should probably be a warning and not error (since it's not an error - not every API is going to return a JSON body).
The text was updated successfully, but these errors were encountered:
When a request comes back with a status of
ok
but the response body is empty or not json, an error is logged.This is deceiving because we have APIs that don't return a body - only a 200 or 201.
Example:
We've already logged the response as text, so there's no reason to log that the response wasn't json, I don't think. At the very least we should remove the
exc_info=True
from thelog
and it should probably be awarning
and noterror
(since it's not an error - not every API is going to return a JSON body).The text was updated successfully, but these errors were encountered: