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

Method V1.Secrets.KeyValue.V2.PatchSecretAsync throw InvalidOperationException in v1.7.2 #289

Closed
EKovalenok opened this issue Dec 6, 2022 · 4 comments
Assignees
Milestone

Comments

@EKovalenok
Copy link

Describe the bug
Thow exception in Polymath.cs MakeRequestAsync method then execute PatchSecretAsync(), because cannot remove from http message headers, 'Content-Type' header.

VaultSharp Version
1.7.2

Vault Version
1.12.2

Does this work with Vault CLI?
Yes

Sample Code Snippet
Non-confidential snippet of code

Exception Details/Stack Trace/Error Message

Unhandled exception. System.AggregateException: One or more errors occurred. (Misused header name, 'Content-Type'. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.)
 ---> System.InvalidOperationException: Misused header name, 'Content-Type'. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.
   at System.Net.Http.Headers.HttpHeaders.GetHeaderDescriptor(String name)
   at System.Net.Http.Headers.HttpHeaders.Remove(String name)
   at VaultSharp.Core.Polymath.MakeRequestAsync[TResponse](String resourcePath, HttpMethod httpMethod, Object requestData, IDictionary`2 headers, Boolean rawResponse, Action`1 postResponseAction)
   at VaultSharp.Core.Polymath.MakeVaultApiRequest[TResponse](String resourcePath, HttpMethod httpMethod, Object requestData, Boolean rawResponse, Action`1 postResponseAction, String wrapTimeToLive, Boolean unauthenticated)
   at VaultSharp.Core.Polymath.MakeVaultApiRequest[TResponse](String mountPoint, String path, HttpMethod httpMethod, Object requestData, Boolean rawResponse, Action`1 postResponseAction, String wrapTimeToLive, Boolean unauthenticated)
   at VaultSharp.V1.SecretsEngines.KeyValue.V2.KeyValueSecretsEngineV2Provider.PatchSecretAsync(String path, PatchSecretDataRequest patchSecretDataRequest, String mountPoint)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at Program.<Main>$(String[] args) in /Users/ekovalenok/Repositories/common-vault/samples/Vault.Sample/Program.cs:line 65


Any additional info
Version 1.7.1 work fine

In 1.7.2 trying remove header 'Content-Type' that does not exist in httpRequestMessage.Headers

Снимок экрана 2022-12-06 в 23 00 45

Снимок экрана 2022-12-06 в 23 02 28

Снимок экрана 2022-12-06 в 23 03 07

@rajanadar rajanadar self-assigned this Dec 7, 2022
@rajanadar rajanadar added this to the 1.7.2.1 milestone Dec 7, 2022
@rajanadar
Copy link
Owner

thanks @EKovalenok for catching this. I'll release a fix by tomorrow. Fix in progress.

@rajanadar
Copy link
Owner

@EKovalenok I have published a fix. Can you please try https://www.nuget.org/packages/VaultSharp/1.7.2.1 ?

@EKovalenok
Copy link
Author

Fixed

@rajanadar
Copy link
Owner

Sweet. Thanks for verifying quickly.

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

No branches or pull requests

2 participants