Skip to content

Setting data of KvV2WriteRequest empty yields a 400 #258

@emilien-puget

Description

@emilien-puget

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions