VaultSharp.Extensions.Configuration icon indicating copy to clipboard operation
VaultSharp.Extensions.Configuration copied to clipboard

fix: handle null values in Vault secrets to prevent NullReference

Open MarcelaCarvalho opened this issue 4 months ago • 0 comments

This PR fixes an issue where the configuration provider throws a NullReferenceException when Vault secrets contain keys with null values. The root cause was an invalid cast of a null value to JsonElement.

The fix adds a null check and creates a JsonElement representing a JSON null (JsonValueKind.Null) when the value is null. This ensures that:

  • Keys with null values are properly included in the configuration.

  • No exceptions are thrown during configuration loading.

  • Consumers of IConfiguration can safely detect and handle keys with null values.

Issue: NullReferenceException when Vault secret contains null values in keys #70

MarcelaCarvalho avatar Sep 15 '25 19:09 MarcelaCarvalho