@@ -34,12 +34,14 @@ import (
3434 pschema "github.com/pulumi/pulumi/pkg/v3/codegen/schema"
3535 "github.com/pulumi/pulumi/sdk/v3/go/common/diag"
3636 "github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
37+ "github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
3738 "github.com/stretchr/testify/assert"
3839 "github.com/stretchr/testify/require"
3940
4041 bridgetesting "github.com/pulumi/pulumi-terraform-bridge/v3/internal/testing"
4142 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
4243 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/info"
44+ "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen/internal/paths"
4345 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfgen/internal/testprovider"
4446 sdkv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
4547 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/x/muxer"
@@ -725,6 +727,54 @@ func TestRegress1626(t *testing.T) {
725727 require .NoError (t , err )
726728}
727729
730+ func Test_DynamicAttributeHandling (t * testing.T ) {
731+ t .Parallel ()
732+
733+ t .Run ("should not panic when processing variable with dynamic attribute" , func (t * testing.T ) {
734+ dynamicVar := & variable {
735+ name : "dynamic_attr" ,
736+ config : true ,
737+ propertyName : paths.PropertyName {Key : "dynamic_attr" , Name : tokens .Name ("dynamicAttr" )},
738+ typ : nil , // This represents a dynamic attribute
739+ }
740+
741+ nt := & schemaNestedTypes {
742+ nameToType : make (map [string ]* schemaNestedType ),
743+ }
744+ assert .NotPanics (t , func () { nt .gatherFromMember (dynamicVar ) })
745+ nt .gatherFromMember (dynamicVar )
746+ assert .Empty (t , nt .nameToType , "Dynamic attributes should not generate nested types" )
747+ })
748+
749+ t .Run ("should handle mixed variable types including dynamic" , func (t * testing.T ) {
750+ strVar := & variable {
751+ name : "string_attr" ,
752+ config : true ,
753+ propertyName : paths.PropertyName {Key : "string_attr" , Name : tokens .Name ("stringAttr" )},
754+ typ : & propertyType {
755+ kind : kindString ,
756+ },
757+ }
758+
759+ dynamicVar := & variable {
760+ name : "dynamic_attr" ,
761+ config : true ,
762+ propertyName : paths.PropertyName {Key : "dynamic_attr" , Name : tokens .Name ("dynamicAttr" )},
763+ typ : nil , // Dynamic attribute
764+ }
765+
766+ // Create a module with both variables
767+ mod := & module {
768+ members : []moduleMember {strVar , dynamicVar },
769+ }
770+
771+ assert .NotPanics (t , func () { gatherSchemaNestedTypesForModule (mod ) })
772+ result := gatherSchemaNestedTypesForModule (mod )
773+ assert .NotNil (t , result , "Result should not be nil" )
774+ assert .Empty (t , result , "Dynamic attributes should not generate nested types" )
775+ })
776+ }
777+
728778func TestSinkHclDiagnostics (t * testing.T ) {
729779 t .Parallel ()
730780
0 commit comments