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

InvalidRequest: 400 Bad Request: invalid header value #337

Open
lvrfrc87 opened this issue Nov 16, 2018 · 3 comments
Open

InvalidRequest: 400 Bad Request: invalid header value #337

lvrfrc87 opened this issue Nov 16, 2018 · 3 comments
Labels
bug waiting-reply waiting for more information (probably for a while)

Comments

@lvrfrc87
Copy link

lvrfrc87 commented Nov 16, 2018

python 3.7 - client.read return 400 bad request.


>>> import os
>>> import hvac
>>> vault_client = hvac.Client(url='http:https://localhost:8200',token=os.environ['VAULT_TOKEN'])
>>>
>>>
>>>
>>> vault_point = vault_client.read('secret/db')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/hvac/v1/__init__.py", line 195, in read
    return self._adapter.get('/v1/{0}'.format(path), wrap_ttl=wrap_ttl).json()
  File "/usr/local/lib/python3.7/site-packages/hvac/adapters.py", line 93, in get
    return self.request('get', url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/hvac/adapters.py", line 265, in request
    utils.raise_for_error(response.status_code, text, errors=errors)
  File "/usr/local/lib/python3.7/site-packages/hvac/utils.py", line 29, in raise_for_error
    raise exceptions.InvalidRequest(message, errors=errors)
hvac.exceptions.InvalidRequest: 400 Bad Request: invalid header value
 vault read -address=${VAULT_ADDR} secret/db
Key                 Value
---                 -----
refresh_interval    768h
password            supersecretpassword
user                root
@jeffwecan
Copy link
Member

I'm unable to replicate with a fresh dev vault server:

$ ipython
Python 3.7.1 (default, Nov  6 2018, 18:45:35)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import os

In [2]: import hvac

In [3]: vault_client = hvac.Client(url='http:https://localhost:8200',token=os.environ['VAULT_TOKEN'])

In [4]: vault_point = vault_client.read('secret/db')

In [5]: print(vault_point)
None

Are there any other replication steps you can think of that would help trigger the same exceptional case?

@jeffwecan jeffwecan added bug waiting-reply waiting for more information (probably for a while) labels Nov 19, 2018
@jeffwecan jeffwecan added this to Needs triage in Bug / Feature Request Triage via automation Nov 24, 2018
@jeffwecan jeffwecan moved this from Needs triage to Waiting Reply in Bug / Feature Request Triage Nov 24, 2018
@jeffwecan jeffwecan moved this from Waiting Reply to Needs triage in Bug / Feature Request Triage Jan 18, 2019
@jeffwecan jeffwecan moved this from Needs triage to Waiting Reply in Bug / Feature Request Triage Jan 29, 2019
@laviua
Copy link

laviua commented May 15, 2020

it's connected with the fact, that native python http client has a validation by regexp:
_is_illegal_header_value = re.compile(rb'\n(?![ \t])|\r(?![ \t\n])').search
take a look that your token doesn't have any escape sequences like this: \n or \r in the end of your line

@davidmontoyago
Copy link

This could happen if the vault token value has been accidentally set with a line break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug waiting-reply waiting for more information (probably for a while)
Projects
Development

No branches or pull requests

4 participants