Open fsackur opened 3 years ago
Possibly something like this for the error at https://github.com/PowerShell/SecretManagement/blob/b1fbbd0/src/code/SecretManagement.cs#L288 ?
var invalidException = new PSInvalidOperationException(
message: string.Format(CultureInfo.InvariantCulture,
"{0} is not a valid SecretManagement extension: {1}", moduleInfo.Name, error.Message
)
innerException: error);
The user would see:
PasswordSafe.Extension is not a valid SecretManagement extension: Test-SecretVault function not found.
From the SecretManagement README.md file:
This module script implements the five functions, as cmdlets, required by SecretManagement, plus one optional function.
It also implements an optional `Unregister-SecretVault` function that is called during vault extension un-registration.
It also implements an optional function `Set-SecretInfo` function that sets secret metadata to a specific secret in the vault.
So this can be made more clear.
Will update the error message and bubble up inner exception message, but in the mean time you can look at the inner exception for more error details (Get-Error command will dump all exception information).
PS> Get-Error
...
Message : Could not find a SecretManagement extension implementing script module.
InnerException :
Type : System.Management.Automation.ItemNotFoundException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Test-SecretVault function not found.
HResult : -2146233087
CategoryInfo : InvalidArgument: (:String) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : SessionStateException
**Message : Test-SecretVault function not found.**
...
Yes, and I do see that the info was there if I'd looked harder!
EDIT: I forked in order to PR a README change, and spotted what I'd missed - d'oh! The correct commands are called out in README.md#L157
FunctionsToExport = @('Set-Secret','Get-Secret','Remove-Secret','Get-SecretInfo','Test-SecretVault')
and with#Optional
comments above the optional functions. I missed that :-( However, I still think this issue points to a possible improvement.Following the help, I implemented an Extension script module with the following functions:
However, vault registration failed:
I inspected the source and found that
Set-SecretInfo
is not a required command, butTest-SecretVault
is: https://github.com/PowerShell/SecretManagement/blob/b1fbbd0/src/code/SecretManagement.cs#L495-L511The UX would be better if this were made clearer in the README, and/or the exact error message were propagated upwards. With NormalView, the error seen is:
That could potentially tell us exactly what command or parameter is missing...?