[GH-ISSUE #175] HCL parser fails on multi-line boolean expressions with && operator #105

Closed
opened 2026-05-06 12:37:31 +02:00 by BreizhHardware · 1 comment

Originally created by @mmclane on GitHub (Mar 23, 2026).
Original GitHub issue: https://github.com/patrickchugh/terravision/issues/175

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.

Originally created by @mmclane on GitHub (Mar 23, 2026). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/175 ## 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 ```hcl 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: ```hcl 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.
Author
Owner

@mmclane commented on GitHub (Mar 23, 2026):

I have worked around this issue for now by converting it to a single line string.

<!-- gh-comment-id:4111217987 --> @mmclane commented on GitHub (Mar 23, 2026): I have worked around this issue for now by converting it to a single line string.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/terravision#105
No description provided.