Skip to content

Commit

Permalink
Merge pull request #22314 from hashicorp/pselle/double-dynamic
Browse files Browse the repository at this point in the history
Fix panic on double dynamic blocks
  • Loading branch information
Pam Selle authored Aug 16, 2019
2 parents f7b1ef8 + 234c1c4 commit e38d588
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lang/blocktoattr/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ func walkVariables(node dynblock.WalkVariablesNode, body hcl.Body, schema *confi
for _, child := range children {
if blockS, exists := schema.BlockTypes[child.BlockTypeName]; exists {
vars = append(vars, walkVariables(child.Node, child.Body(), &blockS.Block)...)
} else if attrS, exists := schema.Attributes[child.BlockTypeName]; exists && attrS.Type.ElementType().IsObjectType() {
} else if attrS, exists := schema.Attributes[child.BlockTypeName]; exists && attrS.Type.IsCollectionType() && attrS.Type.ElementType().IsObjectType() {
// ☝️Check for collection type before element type, because if this is a mis-placed reference,
// a panic here will prevent other useful diags from being elevated to show the user what to fix
synthSchema := SchemaForCtyElementType(attrS.Type.ElementType())
vars = append(vars, walkVariables(child.Node, child.Body(), synthSchema)...)
}
Expand Down

0 comments on commit e38d588

Please sign in to comment.