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

Setting data of KvV2WriteRequest empty yields a 400 #258

Open
emilien-puget opened this issue Mar 27, 2024 · 0 comments · May be fixed by #259
Open

Setting data of KvV2WriteRequest empty yields a 400 #258

emilien-puget opened this issue Mar 27, 2024 · 0 comments · May be fixed by #259

Comments

@emilien-puget
Copy link

Expected Behavior

Using KvV2Write with empty data should clear the secrets of keys

https://developer.hashicorp.com/vault/api-docs/secret/kv/kv-v2#create-update-secret

Current Behavior

Using KvV2Write with empty data yields a 400 with a message stating "no data provided"

Failure Information

vault-client-go v0.4.3
vault 1.13.3

Steps to Reproduce

KvV2Write(ctx, subpath, schema.KvV2WriteRequest{
		Data: make(map[string]interface{}),
	})

Additional Information

i managed to fix this by changing the struct to this

// KvV2WriteRequest struct for KvV2WriteRequest
type KvV2WriteRequest struct {
	// The contents of the data map will be stored and returned on read.
	Data map[string]interface{} `json:"data"`

	// Options for writing a KV entry. Set the \"cas\" value to use a Check-And-Set operation. If not set the write will be allowed. If set to 0 a write will only be allowed if the key doesn’t exist. If the index is non-zero the write will only be allowed if the key’s current version matches the version specified in the cas parameter.
	Options map[string]interface{} `json:"options,omitempty"`

	// If provided during a read, the value at the version number will be returned
	Version int32 `json:"version,omitempty"`
}

by removing the omitempty, the data is correctly sent in the json as an empty object and the vault backend understands the request

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

Successfully merging a pull request may close this issue.

1 participant