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

Work around issues with urllib and LIST request method #773

Open
ethanhs opened this issue Oct 3, 2021 · 2 comments
Open

Work around issues with urllib and LIST request method #773

ethanhs opened this issue Oct 3, 2021 · 2 comments

Comments

@ethanhs
Copy link

ethanhs commented Oct 3, 2021

When using hvac I ran into an issue where I kept getting 400: Bad Request when I tried to list secrets.

The following gives me a 400:

from urllib.request import Request, urlopen
urlopen(Request(url='https://server/v1/mount/metadata/folder', headers={'X-Vault-Token': 'my-token'}, method='LIST'))

However using the list=true query parameter and GET:

from urllib.request import Request, urlopen
urlopen(Request(url='https://server/v1/mount/metadata/folder?list=true', headers={'X-Vault-Token': 'my-token'}, method='GET'))

The request works fine.

I've been able to reproduce this issue across Linux/Python 3.7 and Windows/Python 3.9

Could hvac switch to using the query parameter to work around this issue?

@tommyzli
Copy link

If you initialize hvac.Client with strict_http=True, it will rewrite the LIST requests as GETs with the list query parameter: #689

@Ashap97
Copy link

Ashap97 commented Jul 17, 2024

Hi guys!

I faced with similar issue with the PKI secrets engine:

hvac.exceptions.InvalidRequest: Bad Request, on list https://vault_domain/v1/pki/issuers

According to the the advice but when I'm changing this parameter strict_http to "True" in adapters I'm facing a new issue for PKI secrets engine:

hvac.exceptions.InvalidPath: 1 error occurred:
* unsupported path

, on get https://vault_domain/v1/pki/issuer

Seems that after changing to the GET request it's using the wrong API URL (GET request used for read_issuer method). I'm facing this issue in all list methods (e.g. list_certificates, list_roles etc.)

I have Python 3.11 version, hvac version 2.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants