mustn't decode empty download
See original GitHub issueIn connection.py
the method r.json
will assert if there is no reply content (as i.e. if the HTTP returncode is 401)
Most probably a change like that could make it run smoother:
def reload(self) :
...
data = [];
if r.content.length > 0:
data = r.json()
else if r.status_code == 401:
data["errorMessage"] = "Unauthorized"
Else the user will just get an exception like that:
File "/usr/local/lib/python2.7/dist-packages/pyArango/connection.py", line 102, in __init__
self.reload()
File "/usr/local/lib/python2.7/dist-packages/pyArango/connection.py", line 121, in reload
data = r.json()
File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 894, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
which won’t give much information on the original error.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
A safe way in Ruby to download a file to disk using open-uri ...
A safe way in Ruby to download a file to disk using open-uri ... url = URI.encode(URI.decode(url)) ... Here we mustn't use simple...
Read more >Swift Codable decode empty json as nil or empty object
First time I was facing this, normally backend would send nil but I was receiving empty data. Just make the data inside User...
Read more >Error Handling with Combine and SwiftUI - Peter Friese
An empty username will result in a emptyName error message, indicating the username mustn't be empty. Some usernames are forbidden: "admin" or " ......
Read more >Troubleshoot the Install Application task sequence step
Describes the Install Application task sequence step and how to troubleshoot common problems.
Read more >1. ConfigObj 5 Introduction and Reference
Here we show creating an empty ConfigObj, setting a filename and some values, ... By default ConfigObj does not decode the file/strings you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed it.
wouldn’t we need to implement this thing in every http call everywhere?