@@ -200,13 +200,13 @@ func (s *AttrSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel, ct
200
200
if ! exists {
201
201
// We don't need to check required and emit a diagnostic here, because
202
202
// that would already have happened when building "content".
203
- return cty .NullVal (s .Type ), nil
203
+ return cty .NullVal (s .Type . WithoutOptionalAttributesDeep () ), nil
204
204
}
205
205
206
206
if decodeFn := customdecode .CustomExpressionDecoderForType (s .Type ); decodeFn != nil {
207
207
v , diags := decodeFn (attr .Expr , ctx )
208
208
if v == cty .NilVal {
209
- v = cty .UnknownVal (s .Type )
209
+ v = cty .UnknownVal (s .Type . WithoutOptionalAttributesDeep () )
210
210
}
211
211
return v , diags
212
212
}
@@ -229,7 +229,7 @@ func (s *AttrSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel, ct
229
229
})
230
230
// We'll return an unknown value of the _correct_ type so that the
231
231
// incomplete result can still be used for some analysis use-cases.
232
- val = cty .UnknownVal (s .Type )
232
+ val = cty .UnknownVal (s .Type . WithoutOptionalAttributesDeep () )
233
233
} else {
234
234
val = convVal
235
235
}
@@ -381,7 +381,7 @@ func (s *BlockSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel, c
381
381
Subject : & content .MissingItemRange ,
382
382
})
383
383
}
384
- return cty .NullVal (s .Nested .impliedType ()), diags
384
+ return cty .NullVal (s .Nested .impliedType (). WithoutOptionalAttributesDeep () ), diags
385
385
}
386
386
387
387
if s .Nested == nil {
@@ -478,7 +478,7 @@ func (s *BlockListSpec) decode(content *hcl.BodyContent, blockLabels []blockLabe
478
478
if u .Unknown () {
479
479
// If any block Body is unknown, then the entire block value
480
480
// must be unknown
481
- return cty .UnknownVal (s .impliedType ()), diags
481
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
482
482
}
483
483
}
484
484
@@ -640,7 +640,7 @@ func (s *BlockTupleSpec) decode(content *hcl.BodyContent, blockLabels []blockLab
640
640
if u .Unknown () {
641
641
// If any block Body is unknown, then the entire block value
642
642
// must be unknown
643
- return cty .UnknownVal (s .impliedType ()), diags
643
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
644
644
}
645
645
}
646
646
@@ -763,7 +763,7 @@ func (s *BlockSetSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel
763
763
if u .Unknown () {
764
764
// If any block Body is unknown, then the entire block value
765
765
// must be unknown
766
- return cty .UnknownVal (s .impliedType ()), diags
766
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
767
767
}
768
768
}
769
769
@@ -922,7 +922,7 @@ func (s *BlockMapSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel
922
922
if u .Unknown () {
923
923
// If any block Body is unknown, then the entire block value
924
924
// must be unknown
925
- return cty .UnknownVal (s .impliedType ()), diags
925
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
926
926
}
927
927
}
928
928
@@ -1076,7 +1076,7 @@ func (s *BlockObjectSpec) decode(content *hcl.BodyContent, blockLabels []blockLa
1076
1076
if u .Unknown () {
1077
1077
// If any block Body is unknown, then the entire block value
1078
1078
// must be unknown
1079
- return cty .UnknownVal (s .impliedType ()), diags
1079
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
1080
1080
}
1081
1081
}
1082
1082
@@ -1250,7 +1250,7 @@ func (s *BlockAttrsSpec) decode(content *hcl.BodyContent, blockLabels []blockLab
1250
1250
Subject : & content .MissingItemRange ,
1251
1251
})
1252
1252
}
1253
- return cty .NullVal (cty .Map (s .ElementType )), diags
1253
+ return cty .NullVal (cty .Map (s .ElementType ). WithoutOptionalAttributesDeep () ), diags
1254
1254
}
1255
1255
if other != nil {
1256
1256
diags = append (diags , & hcl.Diagnostic {
@@ -1513,7 +1513,7 @@ func (s *TransformExprSpec) decode(content *hcl.BodyContent, blockLabels []block
1513
1513
// We won't try to run our function in this case, because it'll probably
1514
1514
// generate confusing additional errors that will distract from the
1515
1515
// root cause.
1516
- return cty .UnknownVal (s .impliedType ()), diags
1516
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
1517
1517
}
1518
1518
1519
1519
chiCtx := s .TransformCtx .NewChild ()
@@ -1569,7 +1569,7 @@ func (s *TransformFuncSpec) decode(content *hcl.BodyContent, blockLabels []block
1569
1569
// We won't try to run our function in this case, because it'll probably
1570
1570
// generate confusing additional errors that will distract from the
1571
1571
// root cause.
1572
- return cty .UnknownVal (s .impliedType ()), diags
1572
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
1573
1573
}
1574
1574
1575
1575
resultVal , err := s .Func .Call ([]cty.Value {wrappedVal })
@@ -1583,7 +1583,7 @@ func (s *TransformFuncSpec) decode(content *hcl.BodyContent, blockLabels []block
1583
1583
Detail : fmt .Sprintf ("Decoder transform returned an error: %s" , err ),
1584
1584
Subject : s .sourceRange (content , blockLabels ).Ptr (),
1585
1585
})
1586
- return cty .UnknownVal (s .impliedType ()), diags
1586
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
1587
1587
}
1588
1588
1589
1589
return resultVal , diags
@@ -1637,7 +1637,7 @@ func (s *RefineValueSpec) decode(content *hcl.BodyContent, blockLabels []blockLa
1637
1637
// We won't try to run our function in this case, because it'll probably
1638
1638
// generate confusing additional errors that will distract from the
1639
1639
// root cause.
1640
- return cty .UnknownVal (s .impliedType ()), diags
1640
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
1641
1641
}
1642
1642
1643
1643
return wrappedVal .RefineWith (s .Refine ), diags
@@ -1658,7 +1658,6 @@ func (s *RefineValueSpec) sourceRange(content *hcl.BodyContent, blockLabels []bl
1658
1658
// The Subject field of the returned Diagnostic is optional. If not
1659
1659
// specified, it is automatically populated with the range covered by
1660
1660
// the wrapped spec.
1661
- //
1662
1661
type ValidateSpec struct {
1663
1662
Wrapped Spec
1664
1663
Func func (value cty.Value ) hcl.Diagnostics
@@ -1674,7 +1673,7 @@ func (s *ValidateSpec) decode(content *hcl.BodyContent, blockLabels []blockLabel
1674
1673
// We won't try to run our function in this case, because it'll probably
1675
1674
// generate confusing additional errors that will distract from the
1676
1675
// root cause.
1677
- return cty .UnknownVal (s .impliedType ()), diags
1676
+ return cty .UnknownVal (s .impliedType (). WithoutOptionalAttributesDeep () ), diags
1678
1677
}
1679
1678
1680
1679
validateDiags := s .Func (wrappedVal )
0 commit comments