hashicorp / vault-client-go

HashiCorp Vault Go Client Library generated from OpenAPI spec.
Mozilla Public License 2.0
84 stars 17 forks source link

client.Secrets.KvV1Read fails because of SDK-added parameter #186

Closed erwinvaneyk closed 1 year ago

erwinvaneyk commented 1 year ago

When trying to retrieve a key-value from the secrets engine, I get back a not found for a key that does exist:

vaultClient.Secrets.KvV1Read(ctx, key)

(I am using the v1 API for legacy reasons)

Expected Behavior

I expect to be able to read the secret stored with the given key.

Current Behavior

I get back a 404.

Failure Information

Please include the version of Vault binary and the version of vault-client-go you're using. vault-client-go: 0.3.3 vault: 1.13.4

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. store a KV-pair in secret engine
  2. retrieve the secret using the client.Secrets.KvV1Read call ...

Additional Information

As a workaround that I used a custom request callback function:

func fixVaultKvV1ReadRequest(request *http.Request) {
    query := request.URL.Query()
    query.Del("list")
    request.URL.RawQuery = query.Encode()
}

With this set as a request callback the request goes through.

averche commented 1 year ago

Thanks for reporting this, @erwinvaneyk!

This seems to be very similar to the #174 issue with List/Read being mapped to the same method in the OpenAPI spec. The full solution will need to be implemented in hashicorp/vault and/or hashicorp/vault-plugin-secrets-kv but in the meantime your workaround should work. Alternatively, substituting the call with client.Read(ctx, ...) should work as well.