Vault go client returns an empty response on Put/Patch


Currently, we use K8S on-premise with Vault with the Postgress backend.
The Vault version is 1.8.1 and runs in an HA mode (3 instances).

When we use a go client to write a secret:

secret, err := client.KVv2("secret").Put(context.Background(), "my_path", data)

It returns an error: secret not found: after writing to secret/data/my_path
However, when checked, the data exists and it is possible to retrieve it using the following:

secret, err := client.KVv2("secret").Get(context.Background(), "my_path")

With a bit of debugging, we saw that the response code is 204, but the return body len is 0.

Did anyone encounter a similar issue?

I think you attempted to use the KVv2 client to write to a KVv1 secrets engine.

1 Like

You are absolutely right!
Changed to v2 and it works like a charm!

Thank you!