Vscode-terraform: Linting fails under tflint 0.12.0

Created on 8 Oct 2019  ยท  13Comments  ยท  Source: hashicorp/vscode-terraform

Given a very simple Terraform config file (not the real GUIDs and such):

provider "azurerm" {
  version         = "=1.35.0"
  subscription_id = "1fb2265c-7cd1-4d4f-bc67-61d7799765e8"
  tenant_id       = "f6586130-34a9-4ba8-917d-f78e55f72733"
}

resource "azurerm_resource_group" "kubernetes" {
  name     = "myrg"
  location = "West US"
}

Running linting (manually, since it doesn't seem to auto-run?) yields the following error in the output window:

2019-10-08 18:38:54:080 [INFO ] <cmd>lint: undefined issues
2019-10-08 18:38:54:081 [ERROR] <cmd>lint: Linting failed for c:\Users\tillig\Desktop\Terraform TypeError: issues.forEach is not a function

I believe this will be fixed by PR #227

However, if I add something to my config file that would be found by linting, like an unpinned module...

provider "azurerm" {
  version         = "=1.35.0"
  subscription_id = "be62f057-87be-48e5-9c5f-c6fc74ac9d19"
  tenant_id       = "a172c77d-91cf-47f0-a813-30aee710c0dc"
}

resource "azurerm_resource_group" "kubernetes" {
  name     = "tillig-k8s"
  location = "West US"
}

module "unpinned" {
  source = "git://hashicorp.com/consul.git"
}

Running linting yields an error:

2019-10-08 18:44:26:069 [ERROR] <cmd>lint: Linting failed for c:\Users\tillig\Desktop\Terraform Error: Command failed: tflint --format json

I am guessing that when the current tflint finds errors it doesn't exit with 0, it instead appears to exit with 3, so when linting sees any error, it doesn't even try to parse the results.

It appears you can run tflint /force to require it to always exit 0 even if issues are found. Should that be added to the command line parameters?

Most helpful comment

@jeffb4 Are you able to do this update or should I fork and submit a new version of the PR? I'd love to see tflint working.

All 13 comments

If #227 can be pulled in, I'd be happy to add --force to the command line args in a separate PR.

Oh thanks for this. My local tflint was 0.11.2 so I didn't see the behavior change.

I'm experiencing the same Terraform TypeError: issues.forEach is not a function on OSX for tflint version all the way down to 0.10.1, where it finally passed successfully.

instead of adding --force it would be better just handle the error codes as specified by tflint: https://github.com/wata727/tflint/blob/master/README.md#exit-statuses

happy to do a release if we just fix that thing aswell

@jeffb4 Are you able to do this update or should I fork and submit a new version of the PR? I'd love to see tflint working.

@tillig I'm unable to do this update, sorry for the delay in response

Fair enough. I'll do my best to tackle it when I get a little breathing room.

I'm experiencing the same error with tflint 0.13.4.

PR submitted to handle exit codes and the new output format, which is a much deeper structure than it used to be.

I'm experiencing this as well with terraform 0.12 - is there nothing which can be done as a workaround to get tflint working in VS Code?

We just released v2.0.0-rc.1 of the extension. The main features include:

  • Added syntax support for 0.12
  • Added terraform-ls usage by default (currently on 0.3.0, which offers basic provider code completion)

You can find additional information and specifics in the release notes and CHANGELOG.

With this release we expect that many of the prior issues and PRs are no longer relevant or have been addressed, and are therefore being closed. If you feel the action taken on an issue or PR is in error, please comment as such and we can figure out the appropriate way to address it.

We plan to add the final 2.0.0 release to the marketplace soon, but are actively seeking your feedback now on the release candidates. You can download the .vsix from the releases page and manually install it in VS Code to try it out.

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the context necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

visokoo picture visokoo  ยท  3Comments

brodster2 picture brodster2  ยท  5Comments

bnm22 picture bnm22  ยท  6Comments

chrisgallivan picture chrisgallivan  ยท  4Comments

vazkarvishal picture vazkarvishal  ยท  5Comments