-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Description
In file.py line 50, imagekit expects a resp.json() -- unfortunately in some error cases the resp is not a JSON response (I suspect). The error isn't reported as an imagekit error, but a much more low-level simplejson error. I would expect that imagekit would catch this error and report back it's own error. Either the server-side returns JSON on error (the existing code assumes it would) OR we change this code to handle the error better.
Just an idea, forgive me for any mistakes.
imagekit-python/imagekitio/file.py
Lines 49 to 50 in 3856524
| if resp.status_code > 200: | |
| error = resp.json() |
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "OMITTED", line XXX, in XXX
uploaded = imagekit.upload_file(
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/imagekitio/client.py", line 38, in upload_file
return self.file.upload(file, file_name, options)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/imagekitio/file.py", line 50, in upload
error = resp.json()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Metadata
Metadata
Assignees
Labels
No labels