Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #46

Closed
HeathNaylor opened this issue Mar 25, 2016 · 3 comments
Labels
waiting-reply waiting for more information (probably for a while)

Comments

@HeathNaylor
Copy link

For simplicity sake I have user a and b for my app_id and user_id respectively.

Traceback (most recent call last):
  File "/etc/salt/bash/vault.py", line 30, in <module>
    client.auth_app_id('a', 'b')
  File "/usr/local/lib/python2.7/dist-packages/hvac/v1/__init__.py", line 412, in auth_app_id
    return self.auth('/v1/auth/{0}/login'.format(mount_point), json=params, use_token=use_token)
  File "/usr/local/lib/python2.7/dist-packages/hvac/v1/__init__.py", line 524, in auth
    response = self._post(url, **kwargs).json()
  File "/usr/local/lib/python2.7/dist-packages/hvac/v1/__init__.py", line 561, in _post
    return self.__request('post', url, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/hvac/v1/__init__.py", line 587, in __request
    errors = response.json().get('errors')
  File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 808, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 488, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 389, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Simplification of my script:

import os
import sys
import hvac

client = hvac.Client(url=os.environ.get("VAULT_ADDR"), verify=False)
client.auth_app_id('a', 'b')
@ianunruh
Copy link
Member

Which version of Vault are you using?

@ianunruh ianunruh added the waiting-reply waiting for more information (probably for a while) label Mar 26, 2016
@ianunruh
Copy link
Member

Closing since I can't reproduce on my end. When using an invalid user id/app id combo, I get back an InvalidRequest exception, not a JSON parsing error.

@ahlinc
Copy link
Contributor

ahlinc commented Jun 1, 2016

I've proposed solution here #54 and added test_broken_token test that reproduces similar issue in the code line errors = response.json().get('errors') when the Vault server sends text/plain response. I suppose such responses happen in the Vault when an exception raised outside of Vault code in the net/http golang library.

ianunruh pushed a commit that referenced this issue Jun 15, 2016
] (#54)

* Fix unhandled JSONDecodeError exception on text/plain responces [GH-46]

* Show Vault errors list or response.text in any way on error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-reply waiting for more information (probably for a while)
Projects
None yet
Development

No branches or pull requests

3 participants