Skip to content

Issue in converting Terraform into Intermediate Representation #63

@Tianyi2

Description

@Tianyi2

Describe the bug
When attempting to convert a Terraform file into GLITCH's intermediate representation using the --mode repr option, the tool encounters an error: AttributeError: 'Attribute' object has no attribute 'column'. This error prevents the successful generation of the intermediate representation.

To Reproduce
The command I use: glitch --tech terraform --mode repr /Personal' ' Storage/Project/research/glitch/playground/boolean_value_assign. Note that I create a playground folder in the glitch project.

Steps to reproduce the behavior:

  1. Have a Terraform file named boolean_value_assign.tf located at /playground/boolean_value_assign.tf. I get the file from https://github.com/sr-lab/GLITCH/blob/main/glitch/tests/parser/terraform/files/boolean_value_assign.tf
  2. Execute the following command in the terminal:
  3. glitch --tech terraform --mode repr /Personal' 'Storage/Project/research/glitch/playground/boolean_value_assign.tf
  4. Observe the AttributeError: 'Attribute' object has no attribute 'column' traceback.

Expected behavior
I expected GLITCH to successfully parse the Terraform file and generate its intermediate representation without any errors. The command should complete, and the representation should be outputted (or saved to a file, depending on GLITCH's default behavior for this mode).

Screenshots
Image

Desktop (please complete the following information):

  • OS: [Windows 11]
  • Python: 3.11
  • Download GLITCH with poetry install

Additional Context
When I test with another terraform file "backend.tf" with the following content the above issue does not occur, but generate an "empty IR".
The content in backend.tf

backend "s3" {
bucket = "s3bucketName" // s3 bucket name created from AWS console
key = "terraform.tfstate" // terraform state file
region = "" // provide s3 bucket region
}
}

The output

(.venv1) PS D:\Personal Storage\Project\research\glitch> glitch --tech terraform --mode repr /Personal' 'Storage/Project/research/glitch/playground/backend.tf             
{
  "ir_type": "UnitBlock",
  "line": -1,
  "column": -1,
  "code": "",
  "statements": [],
  "dependencies": [],
  "comments": [],
  "variables": [],
  "atomic_units": [],
  "unit_blocks": [],
  "attributes": [],
  "name": "/Personal Storage/Project/research/glitch/playground/backend.tf",
  "path": "/Personal Storage/Project/research/glitch/playground/backend.tf",
  "type": "unknown"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions