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

Template casting errors caused by concurrencyId property #400

Open
emperortomato opened this issue May 16, 2024 · 1 comment
Open

Template casting errors caused by concurrencyId property #400

emperortomato opened this issue May 16, 2024 · 1 comment
Labels
bug Something isn't working C# Class issue

Comments

@emperortomato
Copy link

Verified issue does not already exist?

Yes

What error did you receive

Using Thycotic.SecretServer module version 0.61.8 in PowerShell v7 against Secret Server version 11.7.000001. We are seeing errors trying to use template functions (e.g., Get-TssSecretTemplate) that cast the REST response to the [Thycotic.PowerShell.SecretTemplates.Template] type:

Error: "Cannot convert the "@{id=101; concurrencyId=45d0bd44-c076-4f0e-8848-8709404ca5c2; name=Example_Template_Name; fields=System.Object[]; passwordTypeId=}" value of type "System.Management.Automation.PSCustomObject" to type "Thycotic.PowerShell.SecretTemplates.Template"."

The concurrencyId property seems to be causing the problem. We've found that we can work around this by removing that property before the cast. E.g., right above the cast to the Template type:

https://github.com/thycotic-ps/thycotic.secretserver/blob/dev/src/functions/secret-templates/Get-TssSecretTemplate.ps1#L64

                if ($restResponse) {
                    [Thycotic.PowerShell.SecretTemplates.Template]$restResponse
                }

Remove the concurrencyId property, like so:

                if ($restResponse) {
                    if ($restResponse.concurrencyId) {
                        $restResponse.PSObject.Properties.Remove('concurrencyID')
                    }
                    [Thycotic.PowerShell.SecretTemplates.Template]$restResponse
                }

Please run the command using -Verbose

No response

Provide a test case or steps to reproduce

Use the product versions described above and try to get a template with Get-TssSecretTemplate.

Expected behavior

Template object is returned.

What Edition of Secret Server?

Professional

What version of Secret Server

Current GA release

What PowerShell host was used when producing this error

PowerShell Core (pwsh)

PowerShell Host Version

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@emperortomato emperortomato added bug Something isn't working triage needed new issues that are still in state of triage labels May 16, 2024
@jagger jagger added C# Class issue and removed triage needed new issues that are still in state of triage labels May 16, 2024
@jagger
Copy link
Contributor

jagger commented May 16, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C# Class issue
Projects
None yet
Development

No branches or pull requests

2 participants