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

404 response for LIST sys/config/ui/headers endpoint if no headers set #20740

Closed
maxiscoding28 opened this issue May 24, 2023 · 6 comments
Closed
Assignees

Comments

@maxiscoding28
Copy link
Contributor

Describe the bug
If no header is configured for via the sys/config/ui/headers/:name endpoint then a 404 error is returned by the list ui headers endpoint
https://developer.hashicorp.com/vault/api-docs/system/config-ui#list-ui-headers

To Reproduce
Steps to reproduce the behavior:

  1. Tested on version Vault 1.13.2+ent
~ vault status -format=json | jq -r '.version'
1.13.2+ent
  1. LIST /sys/config/ui/headers returns 404 if no header is set - https://developer.hashicorp.com/vault/api-docs/system/config-ui#list-ui-headers
~ curl -v -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" \
--request LIST http://127.0.0.1:8200/v1/sys/config/ui/headers
*   Trying 127.0.0.1:8200...
* Connected to 127.0.0.1 (127.0.0.1) port 8200 (#0)
> LIST /v1/sys/config/ui/headers HTTP/1.1
> Host: 127.0.0.1:8200
> User-Agent: curl/7.87.0
> Accept: */*
> X-Vault-Request: true
> X-Vault-Token: XXX
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< Cache-Control: no-store
< Content-Type: application/json
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Date: Wed, 24 May 2023 15:59:49 GMT
< Content-Length: 14
< 
{"errors":[]}
* Connection #0 to host 127.0.0.1 left intact
  1. Set a UI header
curl -v -X PUT -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" \
-d '{"values":"winz"}' http://127.0.0.1:8200/v1/sys/config/ui/headers/X-Custom-Header
  1. LIST /sys/config/ui/headers now returns a 200
~ curl -v -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" \ 
--request LIST http://127.0.0.1:8200/v1/sys/config/ui/headers
*   Trying 127.0.0.1:8200...
* Connected to 127.0.0.1 (127.0.0.1) port 8200 (#0)
> LIST /v1/sys/config/ui/headers HTTP/1.1
> Host: 127.0.0.1:8200
> User-Agent: curl/7.87.0
> Accept: */*
> X-Vault-Request: true
> X-Vault-Token: XXX
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: no-store
< Content-Type: application/json
< Strict-Transport-Security: max-age=31536000; includeSubDomains
< Date: Wed, 24 May 2023 16:04:44 GMT
< Content-Length: 186
< 
{"request_id":"d5a030a5-8d94-987b-6a51-ecc4ae8b3b2d","lease_id":"","renewable":false,"lease_duration":0,"data":{"keys":["X-Custom-Header"]},"wrap_info":null,"warnings":null,"auth":null}
* Connection #0 to host 127.0.0.1 left intact

Expected behavior
A 200 response is returned for the LIST sys/config/ui/headers endpoint even if there are no headers configured.

Environment:
1.13.2

@maxb
Copy link
Contributor

maxb commented May 24, 2023

Although surprising, and probably not the best API design, this behaviour is the same across most (all?) of the LIST endpoints in Vault. It would be weird for sys/config/ui/headers specifically to behave differently.

@marcboudreau
Copy link
Contributor

Thank you for bringing this issue to our attention. Unfortunately, the Vault API has returned HTTP 404 for List operations that do not have any results for quite some time now. We consider the potential adverse effects of changing this behavior would outweigh the clarity that this change would bring.

Given this assessment, I will close this issue. I would encourage you to continue raising issues like this in the future and we will continue to evaluate them to see what can be done on a case by case basis.

@ZhaoZhen711
Copy link

Will documentation be updated to reflect this policy?
https://developer.hashicorp.com/vault/api-docs/system/config-ui#list-ui-headers

@maxb
Copy link
Contributor

maxb commented May 27, 2023

As this is a cross-cutting truth across the entire Vault API, not just one endpoint, it would make more sense to put it in https://developer.hashicorp.com/vault/api-docs, I think.

I'd be open to writing a PR for the docs, but only if someone from HashiCorp is explicitly interested in reviewing and merging it, as I already have 8 open PRs waiting on HashiCorp, some pending for months, and it's getting a bit discouraging.

@stormshield-gt
Copy link

I've just hit a similar problem while listing entity aliases, it should definitely be in the doc

@marcboudreau
Copy link
Contributor

Good suggestion @maxb , I've created #26819 to address this.

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

No branches or pull requests

5 participants