Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terraform_deprecated_index fails to parse .tf.json #100

Closed
1 of 3 tasks
mrwacky42 opened this issue May 30, 2023 · 4 comments
Closed
1 of 3 tasks

terraform_deprecated_index fails to parse .tf.json #100

mrwacky42 opened this issue May 30, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@mrwacky42
Copy link

mrwacky42 commented May 30, 2023

Summary

When escaping quotes in .tf.json files, tflint has a bad day:

$ tflint
Failed to check ruleset; Failed to check `terraform_deprecated_index` rule: test.tf.json:4,28-29: Invalid character; This character is not used within the language.

This looks like the same issue as terraform-linters/tflint#694.

Command

tflint

Terraform Configuration

{
  "locals": {
    "foo": "${local.foo == \"foo\"}"
  }
}

TFLint Configuration

# No config/default.

Output

$ TFLINT_LOG=debug tflint
11:55:36 config.go:136: [INFO] Load config: .tflint.hcl
11:55:36 config.go:146: [INFO] file not found
11:55:36 config.go:154: [INFO] Load config: /Users/sharif/.tflint.hcl
11:55:36 config.go:162: [INFO] file not found
11:55:36 config.go:164: [INFO] Use default config
11:55:36 config.go:319: [INFO] The `terraform` plugin block is not found. Enable the plugin `terraform` automatically
11:55:36 option.go:70: [DEBUG] CLI Options
11:55:36 option.go:71: [DEBUG]   Module: false
11:55:36 option.go:72: [DEBUG]   Force: false
11:55:36 option.go:73: [DEBUG]   Format:
11:55:36 option.go:74: [DEBUG]   Varfiles:
11:55:36 option.go:75: [DEBUG]   Variables:
11:55:36 option.go:76: [DEBUG]   EnableRules:
11:55:36 option.go:77: [DEBUG]   DisableRules:
11:55:36 option.go:78: [DEBUG]   Only:
11:55:36 option.go:79: [DEBUG]   EnablePlugins:
11:55:36 option.go:80: [DEBUG]   IgnoreModules:
11:55:36 loader.go:38: [INFO] Initialize new loader
11:55:36 loader.go:83: [INFO] Module inspection is disabled. Building the root module without children...
11:55:36 runner.go:45: [INFO] Initialize new runner for root
11:55:36 discovery.go:33: [INFO] Plugin `terraform` is not installed, but the bundled plugin is available.
11:55:36 discovery.go:54: [INFO] Plugin `terraform` found
11:55:36 [DEBUG] [email protected]/client.go:604: starting plugin: path=/usr/local/bin/tflint args=["/usr/local/bin/tflint", "--act-as-bundled-plugin"]
11:55:36 [DEBUG] [email protected]/client.go:612: plugin started: path=/usr/local/bin/tflint pid=53415
11:55:36 [DEBUG] [email protected]/client.go:707: waiting for RPC address: path=/usr/local/bin/tflint
11:55:36 [DEBUG] [email protected]/client.go:752: using plugin: version=11
11:55:36 [DEBUG] [email protected]/client.go:1046: tflint: 11:55:36 [DEBUG] [email protected]/server.go:404: plugin address: network=unix address=/var/folders/5f/xtljpwms4k33n8wy6mxd5cdh0000gp/T/plugin1718084009
11:55:36 [DEBUG] host2plugin/client.go:124: starting host-side gRPC server
11:55:36 [DEBUG] [email protected]/client.go:1046: tflint: 11:55:36 [ERROR] interceptor/logging.go:18: failed to gRPC request: direction=host2plugin method=/proto.RuleSet/Check err="rpc error: code = Aborted desc = Failed to check `terraform_deprecated_index` rule: test.tf.json:4,28-29: Invalid character; This character is not used within the language."
11:55:36 [DEBUG] [email protected]/grpc_stdio.go:142: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
11:55:36 [INFO]  [email protected]/client.go:665: plugin process exited: path=/usr/local/bin/tflint pid=53415
11:55:36 [DEBUG] [email protected]/client.go:472: plugin exited
Failed to check ruleset; Failed to check `terraform_deprecated_index` rule: test.tf.json:4,28-29: Invalid character; This character is not used within the language.

TFLint Version

0.46.1

Terraform Version

1.4.6

Operating System

  • Linux
  • macOS
  • Windows
@mrwacky42 mrwacky42 added the bug Something isn't working label May 30, 2023
@bendrucker bendrucker transferred this issue from terraform-linters/tflint May 30, 2023
@bendrucker bendrucker changed the title Trouble parsing .tf.json files terraform_deprecated_index fails to parse .tf.json May 30, 2023
@bendrucker
Copy link
Member

This is resolved in https://github.com/terraform-linters/tflint-ruleset-terraform/releases/tag/v0.3.0 by #90. If you go ahead and specify that plugin version and run tflint --init you'll be set. This is a good idea anyway to enable you to use other plugins and get faster updates.

Otherwise, it's already been updated in TFLint's base branch by Dependabot as well, and so the next CLI release will bundle 0.3.0 or later.

@bendrucker
Copy link
Member

See also #101, prompted by this I noticed that there were false negatives for JSON files. My first step there was adding test coverage against valid cases, including one comparable to yours, which confirmed they are already fixed. But then I was also able to restore detection of legacy syntax too.

@mrwacky42
Copy link
Author

Derp! I didn't bother to realize that there's a separate plugin for HCL itself. Thanks.

@bendrucker
Copy link
Member

All good, it's bundled, so you don't have to notice out of the box. But like I said, a good idea anyway, and will get you patched up immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants