Unable to Patch Existing Secrets Map in VaultSharp
ramyasrimartha opened this issue · comments
Describe the bug
When attempting to patch existing secrets in Vault using VaultSharp, we encounter an issue where patching to add new keys to an existing secrets map fails. While writing and patching secrets individually are successful, attempting to patch secrets to an existing map results in failure. This behavior is inconsistent with the expected functionality and prevents the seamless updating of secrets maps in Vault. As a result, we are unable to effectively manage and update secrets within the Vault environment.
VaultSharp Version
1.13.0.1
Vault Version
1.4.2
Does this work with Vault CLI?
No
Sample Code Snippet
// Successful patching of individual secrets
var value = new Dictionary<string, object> { { "key1", "val1" }};
var writtenValue = await vaultClient.V1.Secrets.KeyValue.V2.WriteSecretAsync(secretPath, value, checkAndSet, mountpoint);
// Successful patching of individual secrets
var valueToBeCombined = new Dictionary<string, object> { { "key1", "new-val1" }};
var patchSecretDataRequest = new PatchSecretDataRequest() { Data = valueToBeCombined };
var metadata = await vaultClient.V1.Secrets.KeyValue.V2.PatchSecretAsync(secretPath, valueToBeCombined, mountpoint);
// Attempt to patch secrets to existing secrets map - fails
var valueToBeCombined = new Dictionary<string, object> { { "key3", "new-val3" }};
var patchSecretDataRequest = new PatchSecretDataRequest() { Data = valueToBeCombined };
var metadata = await vaultClient.V1.Secrets.KeyValue.V2.PatchSecretAsync(secretPath, valueToBeCombined, mountpoint);
Exception Details/Stack Trace/Error Message
Error message, stack trace you see
Any additional info
Helpful info