mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
Block.Filter can panic with no attrs
Make sure that we only dereference an attribute is it was set in the filter. While not extremely useful, a provider could have a nested object with no attributes.
This commit is contained in:
parent
3a75362cce
commit
7ccb21d864
2 changed files with 9 additions and 4 deletions
|
|
@ -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…
Reference in a new issue