Fix nil pointer dereference in config filtering (#3553)

Signed-off-by: Toni Kangas <toni.kangas@upcloud.com>
This commit is contained in:
Toni Kangas
2025-12-09 14:57:52 +02:00
committed by GitHub
parent 3258c67319
commit e5480dd039
2 changed files with 13 additions and 1 deletions

View File

@@ -57,7 +57,7 @@ func (b *Block) Filter(filterAttribute FilterT[*Attribute], filterBlock FilterT[
ret.Attributes[name] = &attr
}
if attr.NestedType != nil {
if ret.Attributes[name] != nil && attr.NestedType != nil {
ret.Attributes[name].NestedType = filterNestedType((&attr).NestedType, filterAttribute)
}
}

View File

@@ -176,6 +176,18 @@ func TestFilter(t *testing.T) {
Nesting: NestingList,
},
},
"read_only_nested": {
NestedType: &Object{
Attributes: map[string]*Attribute{
"string": {
Type: cty.String,
Optional: true,
},
},
Nesting: NestingList,
},
Computed: true,
},
},
BlockTypes: map[string]*NestedBlock{