Skip to content

HCL parser fails on multi-line boolean expressions with && operator #175

@mmclane

Description

@mmclane

Problem

Terravision's HCL parser (lark-based) fails to parse valid Terraform HCL when using the && operator in multi-line boolean expressions.

Error Message

Unexpected token Token('__ANON_8', '&&') at line 42, column 5

Followed by a secondary IndexError in graphmaker.py:1457 when splitting resource names (likely due to corrupted parser state).

Sample Code That Fails

locals {
  create_monitoring_role = (
    var.create_monitoring_role
    && local.db_config.monitoring_role_arn == null
    && local.db_config.monitoring_interval > 0
  )
}

This is valid Terraform HCL syntax (terraform validate passes), but terravision cannot parse it.

Environment

  • Running via Docker image patrickchugh/terravision
  • Terraform source with Aurora database modules

Workaround

Rewriting the expression as a single line works:

locals {
  create_monitoring_role = var.create_monitoring_role && local.db_config.monitoring_role_arn == null && local.db_config.monitoring_interval > 0
}

Expected Behavior

Terravision should parse valid Terraform HCL that uses && operators across multiple lines within parentheses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions