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
Naked identifier map keys are typically not valid references, but can still be successfully evaluated. Despite this, it fails to evaluate in the TFLint plugin SDK. This is exactly the same problem that occurs in terraform-linters/tflint-ruleset-terraform#196, where the test runner doesn't throw an error, but the actual runner does.
The cause of this is in the serialization of expressions. In the actual runner, in order to send an expression via gRPC, it is converted into a byte sequence of the expression's source code and then parsed again as an expression:
Follow up of terraform-linters/tflint-ruleset-terraform#196
Naked identifier map keys are typically not valid references, but can still be successfully evaluated. Despite this, it fails to evaluate in the TFLint plugin SDK. This is exactly the same problem that occurs in terraform-linters/tflint-ruleset-terraform#196, where the test runner doesn't throw an error, but the actual runner does.
The cause of this is in the serialization of expressions. In the actual runner, in order to send an expression via gRPC, it is converted into a byte sequence of the expression's source code and then parsed again as an expression:
tflint-plugin-sdk/plugin/internal/toproto/toproto.go
Lines 117 to 120 in 63caa05
tflint-plugin-sdk/plugin/internal/fromproto/fromproto.go
Line 154 in 63caa05
However, expressions such as map keys are context-sensitive and when parsed in this manner the result is a different expression type.
The
ObjectConsKeyExpr
is a wrapper expression that allows a naked identifier to be evaluated without error.https://github.com/hashicorp/hcl/blob/v2.21.0/hclsyntax/expression.go#L1286-L1292
To fix this in the SDK, we would need to include the fact that the expression was a map key in
proto.Expression
and restore it on the host side.The text was updated successfully, but these errors were encountered: