Closed bendrucker closed 9 months ago
Two general approaches would be:
EmitIssue
to create issues and pass a Range
as its own argument. On further thought it seems like 2 is actually ok given that this is meant to limit errors to expressions that reference module variables. If the expression is invalid it can't contain any variables.
Agreed with 2. 1 is a better approach, but I think module call inspection should stop assuming only issues for expressions in the first place.
In the future it would be good to redesign the plugin API by https://github.com/terraform-linters/tflint-plugin-sdk/issues/193.
Summary
When a ruleset emits an issue with the declaration range of a child block, TFLint will panic if that issue is emitted from a child module. The range itself covers just the block name, which TFLint interprets as an expression, and attempts to parse it for variables. That fails and causes a panic.
See https://github.com/terraform-linters/tflint-ruleset-opa/issues/85
This issue is not directly related to the OPA ruleset plugin. Given the configuration below, the emitted issue range covers
rule
(no braces). TFLint should not assume that the declaration range of a block is a valid expression, because it's not. This happens to work for labeled blocks (e.g.resource "foo" "bar"
, but causes errors for unlabeled blocks which are just one-word identifiers and syntactically look like an expression.Command
tflint
Terraform Configuration
TFLint Configuration
Output
TFLint Version
0.50.2
Terraform Version
No response
Operating System