When filtering emitted issues from child modules, ignore any issue covering an expression that cannot be parsed for references. Fixes a panic described in #1968.
EmitIssue may be called for a range that is not actually a valid Terraform expression. But TFLint just checks whether the range's source is a valid HCL expression. Something like my_block is a valid HCL expression, but it's not a valid expression in Terraform when it's a child block of a resource. Some declaration ranges (e.g., blocks with labels) are not valid HCL expressions either, but unlabeled block declarations (name, without braces) are syntactically valid expressions.
So listVarRefs must handle invalid expressions. Or callers must be able to specify that they are emitting an issue on a non-expression range, which would likely require a breaking change somewhere.
When filtering emitted issues from child modules, ignore any issue covering an expression that cannot be parsed for references. Fixes a panic described in #1968.
EmitIssue
may be called for a range that is not actually a valid Terraform expression. But TFLint just checks whether the range's source is a valid HCL expression. Something likemy_block
is a valid HCL expression, but it's not a valid expression in Terraform when it's a child block of aresource
. Some declaration ranges (e.g., blocks with labels) are not valid HCL expressions either, but unlabeled block declarations (name, without braces) are syntactically valid expressions.So
listVarRefs
must handle invalid expressions. Or callers must be able to specify that they are emitting an issue on a non-expression range, which would likely require a breaking change somewhere.Closes https://github.com/terraform-linters/tflint/issues/1968 Closes https://github.com/terraform-linters/tflint-ruleset-opa/issues/85