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

ThrowInvalidCastException New-AzManagementGroupDeploymentStack / New-AzSubscriptionDeploymentStack New-AzResourceGroupDeploymentStack #26747

Open
rsegers opened this issue Nov 22, 2024 · 1 comment
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved.

Comments

@rsegers
Copy link

rsegers commented Nov 22, 2024

Description

When an input parameter was deserialised from JSON, creating a Deployment Stack (e.g. New-AzManagementGroupDeploymentStack) crashes PowerShell.

This issue does not occur when using the non-deployment stack equivalents (e.g. New-AzManagementGroupDeployment)

It is difficult to gather logs, because PowerShell crashes.
Issue is reproducible in Azure DevOps pipeline running ubuntu-latest

Issue script & Debug output

Bicep file:

param test object
output test object = test

PowerShell:

# With or without -NoEnumerate results in same error
# With or without -AsHashTable results in same error
$test = @{'name'='example'} | ConvertTo-Json | ConvertFrom-Json -NoEnumerate

New-AzManagementGroupDeploymentStack `
    -name 'test' `
    -TemplateFile .\test.bicep `
    -Location westeurope `
    -ManagementGroupId "test" `
    -ActionOnUnmanage DeleteAll `
    -DenySettingsMode None `
    -TemplateParameterObject @{'test'= $test}

Environment data

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

Module versions

13.0.0

Error output

Stack overflow.
   at System.Management.Automation.LanguagePrimitives.ThrowInvalidCastException(System.Object, System.Type)
   at System.Management.Automation.LanguagePrimitives.ConvertNoConversion(System.Object, System.Type, Boolean, System.Management.Automation.PSObject, System.IFormatProvider, System.Management.Automation.Runspaces.TypeTable)
   at System.Management.Automation.LanguagePrimitives.ConvertTo(System.Object, System.Type, Boolean, System.IFormatProvider, System.Management.Automation.Runspaces.TypeTable)
   at System.Management.Automation.LanguagePrimitives.Equals(System.Object, System.Object, Boolean, System.IFormatProvider)
   at System.Collections.Generic.ObjectEqualityComparer`1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].IndexOf(System.__Canon[], System.__Canon, Int32, Int32)
   at System.Array.IndexOf[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon[], System.__Canon, Int32, Int32)
   at System.Collections.Generic.List`1[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Contains(System.__Canon)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.Serialization.JsonProperty, Newtonsoft.Json.Serialization.JsonContract, Newtonsoft.Json.Serialization.JsonContainerContract, Newtonsoft.Json.Serialization.JsonProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(Newtonsoft.Json.JsonWriter, System.Object, Newtonsoft.Json.Serialization.JsonContainerContract, Newtonsoft.Json.Serialization.JsonProperty, Newtonsoft.Json.Serialization.JsonProperty, Newtonsoft.Json.Serialization.JsonContract ByRef, System.Object ByRef)
@rsegers rsegers added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Nov 22, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported needs-triage This is a new issue that needs to be triaged to the appropriate team. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Nov 22, 2024
@VeryEarly VeryEarly removed needs-triage This is a new issue that needs to be triaged to the appropriate team. customer-reported labels Nov 28, 2024
@VeryEarly
Copy link
Contributor

@dantedallag can you please help take a look, thanks

@dantedallag dantedallag self-assigned this Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved.
Projects
None yet
Development

No branches or pull requests

3 participants