Describe the bug
vault kv list fails to retrieve metadata when a trailing white space is found in a component of the path
To Reproduce
Steps to reproduce the behavior:
No value found at secret/metadata/1
Expected behavior
Keys
----
2
Environment:
Vault server configuration file(s):
The bug seems to be right at https://github.com/hashicorp/vault/blob/master/command/kv_list.go#L76 - it sanitizes the path by trimming (does nothing), then removing leading slash (does nothing), then removes ending slash (causes our string to have a trailing whitespace). Then ensureTrailingSlash is called which trims our needed whitespace.
Should be a quick fix...
I think the API / curl may be the best approach & using percent-encoding for spaces (%20) - I've tried the following using 1.5.0 which works well:
vault kv put 'kv/1 /2' 3=4
# Key Value
# --- -----
# created_time 2020-08-09T22:25:33.552447789Z
# deletion_time n/a
# destroyed false
# version 1
vault kv list kv/
# Keys
# ----
# 1 /
# test
curl -s -H "X-Vault-Token: $VAULT_TOKEN" ${VAULT_ADDR}/v1/kv/metadata/1%20/?list=true | jq -r '.data.keys'
# [
# "2"
# ]
vault kv get 'kv/1 /2'
# ====== Metadata ======
# Key Value
# --- -----
# created_time 2020-08-09T22:25:33.552447789Z
# deletion_time n/a
# destroyed false
# version 1
#
# == Data ==
# Key Value
# --- -----
# 3 4
Is this issue still applicable?
Most helpful comment
The bug seems to be right at https://github.com/hashicorp/vault/blob/master/command/kv_list.go#L76 - it sanitizes the path by trimming (does nothing), then removing leading slash (does nothing), then removes ending slash (causes our string to have a trailing whitespace). Then
ensureTrailingSlashis called which trims our needed whitespace.Should be a quick fix...