Merge pull request #34472 from hashicorp/jbardin/schema-filter-attrs

`Block.Filter` can panic with a nested object which has no attributes
pull/34491/head
James Bardin 2 years ago committed by GitHub
commit d94a61735e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -50,10 +50,9 @@ func (b *Block) Filter(filterAttribute FilterT[*Attribute], filterBlock FilterT[
for name, attrS := range b.Attributes {
if filterAttribute == nil || !filterAttribute(name, attrS) {
ret.Attributes[name] = attrS
}
if attrS.NestedType != nil {
ret.Attributes[name].NestedType = filterNestedType(attrS.NestedType, filterAttribute)
if attrS.NestedType != nil {
ret.Attributes[name].NestedType = filterNestedType(attrS.NestedType, filterAttribute)
}
}
}

@ -175,6 +175,12 @@ func TestFilter(t *testing.T) {
Nesting: NestingList,
},
},
"missing_attributes": {
NestedType: &Object{
Nesting: NestingList,
},
Computed: true,
},
},
BlockTypes: map[string]*NestedBlock{

Loading…
Cancel
Save