Skip to content

fix: Get-TssRpcPasswordType Fields array cast failure on SS 12.0#443

Open
jagger wants to merge 1 commit into
thycotic-ps:devfrom
jagger:jagger/fix-440-rpcpasswordtype-fields-array
Open

fix: Get-TssRpcPasswordType Fields array cast failure on SS 12.0#443
jagger wants to merge 1 commit into
thycotic-ps:devfrom
jagger:jagger/fix-440-rpcpasswordtype-fields-array

Conversation

@jagger
Copy link
Copy Markdown
Contributor

@jagger jagger commented May 13, 2026

Summary

On SS 12.0 a password type whose fields array is non-empty trips:

Cannot convert value "..." to type "Thycotic.PowerShell.Rpc.PasswordType".
Error: "Cannot convert value "..." to type "Thycotic.PowerShell.Rpc.PasswordTypeField".
Error: "Cannot convert the "..." value of type "System.Management.Automation.PSCustomObject"
       to type "Thycotic.PowerShell.Rpc.PasswordTypeField"."

FilterTssResponse only filters top-level properties of the outer object — it explicitly doesn't recurse into nested arrays or objects (per #427's design). The fields array survives unfiltered, and PowerShell's outer [PasswordType] cast can't coerce the PSCustomObject[] into PasswordTypeField[].

What changed

  • Pre-coerce each element of $restResponse.fields through FilterTssResponse before the outer cast. After this pass, fields already holds typed PasswordTypeField[] values, so the outer cast assigns the array as-is.
  • Same pattern as the #432 fix for Get-TssConfiguration, adapted for an array-of-objects rather than a single nested object.
  • Search-TssRpcPasswordType doesn't need this change — it returns PasswordTypeSummary[], which is flat (no nested complex types).

Test plan

  • Invoke-Build -File .\build.ps1 -Task . -Configuration Debug — succeeds
  • PowerShell parser validates the cmdlet cleanly
  • Live smoke against SS 12.0.000022: Get-TssRpcPasswordType -TssSession $session -Id <id_with_fields> returns a populated PasswordType with a populated Fields collection of PasswordTypeField — no cast error

Closes #440.

When a password type has a non-empty fields array, the outer
[Thycotic.PowerShell.Rpc.PasswordType] cast failed because PowerShell could
not auto-coerce the array's PSCustomObject elements into PasswordTypeField.
FilterTssResponse only filters the outer object's top-level properties and
explicitly does not recurse into nested objects or arrays.

Pre-coerce each fields element through FilterTssResponse before the outer
cast — the same pattern applied to Get-TssConfiguration (thycotic-ps#432) but adapted
for an array. After this pass, fields holds typed PasswordTypeField[] values
and the outer cast assigns the array as-is without further coercion.

Fixes thycotic-ps#440.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-TssRpcPasswordType: PasswordTypeField nested type cast failure on SS 12.0

1 participant