Closed RatserX closed 1 year ago
hi @RatserX ,
i published the fix as a beta package: https://www.nuget.org/packages/VaultSharp/1.13.0.1-beta1 Can you try and let me know if any issues? If none, I'll publish the proper version
Hi @rajanadar , After doing some tests in our Dev environment I can confirm the beta package fixes the main issue. So far, I haven't seen any other issues happening so I think this is good to go.
Very cool. I'll publish it out in a day.
@RatserX , official version is published: https://www.nuget.org/packages/VaultSharp/1.13.0.1
Thank you so much for the help!
Describe the bug According to the Hashicorp documentation, the
rotation_period
can be stored as a string or an int. However,System.Text.Json
(contrary toNewtonsoft.Json
) does not accept non-string values when deserializing to properties of type string (in this case,VaultSharp.V1.SecretsEngines.Database.RotationPeriod
).Since our
rotation_period
is stored as a number, we're being hit with aJsonException
whenever we try to obtain our credentials usingGetStaticCredentialsAsync
on the latest version of the library.Database Secrets Engine (rotation_period): https://developer.hashicorp.com/vault/api-docs/secret/databases#rotation_period System.Text.Json migration (non-string values): https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft?pivots=dotnet-7-0#non-string-values-for-string-properties
VaultSharp Version 1.13.0
Exception Details/Stack Trace/Error Message System.Text.Json.JsonException: 'The JSON value could not be converted to System.String. Path: $.rotation_period | LineNumber: 0 | BytePositionInLine: 255.' InvalidOperationException: Cannot get the value of a token type 'Number' as a string.
Any additional info I'm thinking a solution would be to create a custom converter that handles converting non-string values to string (similar to how Newtonsoft.Json does it) and then register the JsonConverter on the RotationPeriod property. Idea taken from: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/converters-how-to?pivots=dotnet-7-0#registration-sample---jsonconverter-on-a-property