Skip to content

Commit 82fc2e0

Browse files
Call EnsureNoError after evaluating aws_route expression so unevaluable expressions are skipped (#320)
* Call EnsureNoError after evaluating an expression to ensure unevaluable expressions are skipped * Catch another instance of EnsureNoError not being called
1 parent 31233ac commit 82fc2e0

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

rules/aws_route_not_specified_target.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ func (r *AwsRouteNotSpecifiedTargetRule) Check(runner tflint.Runner) error {
6666
for _, attribute := range resource.Body.Attributes {
6767
var val cty.Value
6868
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
69+
err = runner.EnsureNoError(err, func() error {
70+
if val.IsNull() {
71+
nullAttributes = nullAttributes + 1
72+
}
73+
return nil
74+
})
6975
if err != nil {
7076
return err
7177
}
72-
73-
if val.IsNull() {
74-
nullAttributes = nullAttributes + 1
75-
}
7678
}
7779

7880
if len(resource.Body.Attributes)-nullAttributes == 0 {

rules/aws_route_specified_multiple_targets.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ func (r *AwsRouteSpecifiedMultipleTargetsRule) Check(runner tflint.Runner) error
6666
for _, attribute := range resource.Body.Attributes {
6767
var val cty.Value
6868
err := runner.EvaluateExpr(attribute.Expr, &val, nil)
69+
err = runner.EnsureNoError(err, func() error {
70+
if val.IsNull() {
71+
nullAttributes = nullAttributes + 1
72+
}
73+
return nil
74+
})
6975
if err != nil {
7076
return err
7177
}
7278

73-
if val.IsNull() {
74-
nullAttributes = nullAttributes + 1
75-
}
7679
}
7780

7881
if len(resource.Body.Attributes)-nullAttributes > 1 {

0 commit comments

Comments
 (0)