SecretManagement icon indicating copy to clipboard operation
SecretManagement copied to clipboard

VaultParameters of Type TimeSpan are Converted to HashTable

Open marshallwp opened this issue 8 months ago • 0 comments

Prerequisites

  • [x] Write a descriptive title.
  • [x] Make sure you are able to repro it on the latest released version
  • [x] Search the existing issues.

Steps to reproduce

I've written an extension for PowerShell/SecretManagement that allows users to set an optional VaultParameter during registration called ResyncCacheIfOlderThan. This value is of data type TimeSpan. Recently it has come to my attention that when users supply a VaultParameters hashtable containing this property during vault registration, the TimeSpan is converted to a HashTable. Sadly said Hashtable has no implicit conversion back to TimeSpan, so any functions expecting the latter will fail.

Expected behavior

PS> $VaultParameters = @{
	ResyncCacheIfOlderThan = New-TimeSpan -Hours 2
}
PS> Register-SecretVault -Name "warden2" -ModuleName SecretManagement.Warden -VaultParameters $VaultParameters
PS> (Get-SecretVault -Name warden2).VaultParameters.ResyncCacheIfOlderThan | gm

   TypeName: System.TimeSpan

Actual behavior

PS> $VaultParameters = @{
	ResyncCacheIfOlderThan = New-TimeSpan -Hours 2
}
PS> Register-SecretVault -Name "warden2" -ModuleName SecretManagement.Warden -VaultParameters $VaultParameters
PS> (Get-SecretVault -Name warden2).VaultParameters.ResyncCacheIfOlderThan | gm

   TypeName: System.Collections.Hashtable

Error details


Environment data

Name                           Value
----                           -----
PSVersion                      7.4.7
PSEdition                      Core
GitCommitId                    7.4.7
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

N/A

Visuals

No response

marshallwp avatar Mar 26 '25 17:03 marshallwp