Can't parse dictionnary to create_or_update_secret method
See original GitHub issueBriefly describe the issue:
vault_co.secrets.kv.v2.create_or_update_secret('prod/' + next(iter(server)), secret=secret)
is giving me a
json.decoder.JSONDecodeError
however
vault_co.write('secret/prod/' + next(iter(server)), data=secret)
is working fine.
What did you expect to happen?
create_or_update_secret
seems to not validate the dictionnary in the secret
variable, although write
does.
What did happen?
create_or_update_secret
failed.
Please include helpful code examples so we can attempt to replicate (if applicable):
Here is the variables:
next(iter(server)) = Arthur
secret = {'IP': '192.168.1.4', 'User': 'root', 'Password': 'Pa$$w0rd'}
Here is the Stacktrace:
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/hvac/api/secrets_engines/kv_v2.py", line 124, in create_or_update_secret
return response.json()
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This may be not the correct way to create secrets, as the write
function didn’t parse data correctly:
$ vault kv get secret/prod/Arthur
==== Data ====
Key Value
--- -----
data map[IP:192.168.1.4 Password:Pa$$w0rd User:root]
I expected something like:
==== Data ====
Key Value
--- -----
IP 192.168.1.4
Password Pa$$w0rd
User root
This is maybe related to the create_or_update_secret
issue, however I can’t find the correct way to do it in the documentation.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
check the version of your secret engine
vault secrets list --detailed
, i suspect that your problem is that the secret engine youre using is v1I think it all just depends on the version. I have a 1.2.2 container and that does get kvv2 at
init
Anyways, glad you got working!