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

Unexpected JSON parsing error #129

Closed
tgolsson opened this issue Oct 29, 2021 · 2 comments · Fixed by #130
Closed

Unexpected JSON parsing error #129

tgolsson opened this issue Oct 29, 2021 · 2 comments · Fixed by #130
Labels
bug Something isn't working

Comments

@tgolsson
Copy link
Contributor

Hello!

I'm running into an issue with linting our audit resources, and as far as I can tell our setup is correct, and the JSON is valid. Running tflint on the following data:

{
   "resource": {
      "google_project_iam_audit_config": {
         "iam-audit-conf": {
            "audit_log_config": [
               {
                  "log_type": "DATA_WRITE"
               }
            ],
            "service": "iam.googleapis.com"
         },
         "logging-audit-conf": {
            "audit_log_config": [
               {
                  "log_type": "DATA_READ"
               },
               {
                  "log_type": "ADMIN_READ"
               }
            ],
            "service": "logging.googleapis.com"
         }
      }
   }
}

Generates the following error:

Failed to check ruleset. An error occurred:

Error: Failed to check `google_project_iam_audit_config_invalid_member` rule: xxx.tf.json:3,22-23: Unclosed object; No closing bracket was found for this JSON array., and 1 other diagnostic(s)

This seems like a parsing error in this library, but I've not been able to locate why/where so far. Any thoughts?

@wata727
Copy link
Member

wata727 commented Oct 31, 2021

This seems to be a bug in WalkResourceBlocks. When transferring blocks between plugins, it is necessary to extract the target block (audit_log_config in this case) from the Terraform configuration, but there is a problem with this range extraction in JSON syntax.
https://github.com/terraform-linters/tflint/blob/v0.33.1/tflint/terraform.go#L107-L108

I'm working on a redesign of the plugin API to resolve this problem. Once this is done, this kind of problem will be resolved.
terraform-linters/tflint-plugin-sdk#89

As a workaround, I think it can be avoided by using the WalkResources API instead.

@tgolsson
Copy link
Contributor Author

tgolsson commented Nov 1, 2021

Thank you @wata727!

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

Successfully merging a pull request may close this issue.

2 participants