You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Add an argument to the issues API that allows the rule to instruct on whether or not the range at issue is an expression or a declaration. This is likely to be a breaking change given that callers use 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.
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 terraform-linters/tflint-ruleset-opa#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
The text was updated successfully, but these errors were encountered: