python-librato icon indicating copy to clipboard operation
python-librato copied to clipboard

No JSON object could be decoded

Open Fkawala opened this issue 9 years ago • 3 comments

Hi,

I have trouble using queues (python-librato/librato/queue.py). I create the queue as demonstrated in the docs (see below). The queue auto-submit fails with a ValueError exception that is raised when the response from the server is parsed.

Best, François.

Minimum example:

LIBRATO_USER = '****'
LIBRATO_TOKEN = '****'
api = librato.connect(LIBRATO_USER, LIBRATO_TOKEN)
q = api.new_queue(auto_submit_count=1)
q.add('sdfsdf',1)

Error stack:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/librato/queue.py", line 61, in add
    self.submit()
  File "/usr/local/lib/python2.7/dist-packages/librato/queue.py", line 95, in submit
    self.connection._mexe("metrics", method="POST", query_props=c)
  File "/usr/local/lib/python2.7/dist-packages/librato/__init__.py", line 170, in _mexe
    resp_data, success, backoff = self._process_response(resp, backoff)
  File "/usr/local/lib/python2.7/dist-packages/librato/__init__.py", line 147, in _process_response
    resp_data = json.loads(body.decode(_getcharset(resp)))
  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")
ValueError: No JSON object could be decoded

Fkawala avatar Jun 30 '15 18:06 Fkawala

The problem is related to the authentication. The content of the response that cause the ValueError is:

Credentials are required to access this resource.

Fkawala avatar Jul 01 '15 08:07 Fkawala

@Fkawala Thanks for the report and update. The regular maintainers of this lib are out for the next few days (this is a Holiday week in the US), but they should be able to follow up in improving this case next week.

It sounds like it was an auth issue, were you able to get everything sorted in the meantime?

nextmat avatar Jul 01 '15 17:07 nextmat

@nextmat Thanks for the update, that auth issue is solved.

Fkawala avatar Jul 02 '15 08:07 Fkawala