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

OpenAPI Explorer (Swagger UI) "Try it out" functionality broken for ListOperations / ones with query parameters #18614

Closed
maxb opened this issue Jan 6, 2023 · 9 comments
Labels
bug Used to indicate a potential bug core/openapi devex Developer Experience ui

Comments

@maxb
Copy link
Contributor

maxb commented Jan 6, 2023

Describe the bug
In the embedded Vault API Explorer (Swagger UI), the "Try it out" functionality for making requests from the UI does not work for ListOperations. It fails because the ?list=true query parameter is not added to the request.

To Reproduce
Steps to reproduce the behavior:

  1. Open API explorer (Vault UI, open console dropdown, type "api")
  2. Find a list operation e.g. /identity/entity-alias/id and execute it via "Try it out"
  3. See error "1 error occurred:\n\t* unsupported operation\n\n"

Environment:
Vault 1.12.2 and 1.13-dev

Additional context
Issue is not unique to the mandatory list parameter on ListOperations - the allowed_client_id query parameter is also not populated into the generated request or displayed curl command properly for the /identity/oidc/provider endpoint, for example.

@maxb
Copy link
Contributor Author

maxb commented Jan 18, 2023

Thanks for fixing!

@maxb maxb closed this as completed Jan 18, 2023
@vaerh
Copy link

vaerh commented Jul 2, 2023

Hello! In Vault v1.14.0, built 2023-06-19T11:40:23Z (development mode) we again have broken functionality when trying to list output. Also for this reason, reading metadata in vault-client-go doesn't work.

изображение

@maxb
Copy link
Contributor Author

maxb commented Jul 2, 2023

Hello! In Vault v1.14.0, built 2023-06-19T11:40:23Z (development mode) we again have broken functionality when trying to list output.

OK! But, it's not related to this closed issue, so this isn't a good place to report that.

Actually, I've just loaded up the API Explorer in 1.14.0 and both list and read operations on metadata/{path} of a KV v2 are working fine, and what you have in your screenshot appears to be Vault behaving as expected, when there are no secrets nested under path aaa/ - so I'm not convinced you're actually seeing a bug.

Also for this reason, reading metadata in vault-client-go doesn't work.

No, that's largely unrelated. I've participated in the relevant conversation at hashicorp/vault-client-go#174 and am still intending to follow through on producing a PR, though I've queued that behind my work on hashicorp/vault-client-go#180.

@vaerh
Copy link

vaerh commented Jul 2, 2023

OK! But, it's not related to this closed issue, so this isn't a good place to report that.

Sorry about that. I first posted here, but then I realized that it was better to start a new issue. What's done is done.

I assumed it was necessary to attach a screenshot with normal key data. I can tell you that the key contains information.
изображение

изображение

@maxb
Copy link
Contributor Author

maxb commented Jul 2, 2023

Ah, I see the issue. Thanks for including the curl commands, they're the important bit.

The issue is simply a misunderstanding / lack of docs about how the list operation works on Vault KVs.

You have a key named aaa. You do a list on aaa. You get no results. This is actually expected. (Yes, this is weird if you're comparing to the behaviour of Linux filesystems, and ls.)

Why? Because all list operations in Vault implicitly append a trailing / whether you specify one or not. You're effectively doing a list on the prefix aaa/, and the answer to the question "Do I have any secrets starting with aaa/?" is "No."

Try creating a secret aaa/bbb in addition to aaa. Then, do list operations on /v1/secret/metadata and /v1/secret/metadata/aaa and compare the results. This should allow you observe how Vault KV works, and understand why you've seen the responses you have.

@vaerh
Copy link

vaerh commented Jul 3, 2023

Try creating a secret aaa/bbb in addition to aaa. Then, do list operations on /v1/secret/metadata and /v1/secret/metadata/aaa and compare the results. This should allow you observe how Vault KV works, and understand why you've seen the responses you have.

Thanks, that's an unexpected twist :)

Then there is a back question, do I understand correctly that you can get the metadata of a single secret only with the Read function? KvV2ReadMetadata will not work with this logic.

@maxb
Copy link
Contributor Author

maxb commented Jul 3, 2023

Retrieving KV v2 secret metadata is always a read operation, not a list. It always operates on only a single secret.

The generated client libraries KvV2ReadMetadata function is currently broken, pending necessary changes to Vault's OpenAPI. It will work in the future, once the bug is fixed.

@vaerh
Copy link

vaerh commented Jul 3, 2023

Thank you very much for your help!

It will work in the future, once the bug is fixed.

Well, let's wait. Will the up-to-date information on bug fixing be posted as part of vault-client-go/issues/174?

@maxb
Copy link
Contributor Author

maxb commented Jul 3, 2023

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug core/openapi devex Developer Experience ui
Projects
None yet
Development

No branches or pull requests

3 participants