[GH-ISSUE #176] IndexError in handle_variants when resource name has no dot separator #103

Closed
opened 2026-05-06 12:37:30 +02:00 by BreizhHardware · 3 comments

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

Problem

Terravision crashes with an IndexError in handle_variants() when processing resource names that don't contain a dot (.) separator.

Error Message

Unhandled error: <class 'IndexError'>, list index out of range
Traceback (most recent call last):
  ...
  File "/home/terravision/.local/lib/python3.12/site-packages/modules/graphmaker.py", line 1457, in handle_variants
    variant_label = resource.split(".")[1]
                    ~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Context

This occurs after successfully parsing HCL and processing 231 resources. The error happens during the "Checking for additional links" phase.

The code assumes every resource string will have at least one dot, but some resource identifiers may not follow that pattern.

Environment

  • Running via Docker image patrickchugh/terravision
  • Terraform source with Aurora database modules, S3 buckets, KMS keys, and Route53 records

Suggested Fix

Add a guard before the split:

# Current (line 1457)
variant_label = resource.split(".")[1]

# Suggested
parts = resource.split(".")
variant_label = parts[1] if len(parts) > 1 else resource
Originally created by @mmclane on GitHub (Mar 23, 2026). Original GitHub issue: https://github.com/patrickchugh/terravision/issues/176 ## Problem Terravision crashes with an `IndexError` in `handle_variants()` when processing resource names that don't contain a dot (`.`) separator. ## Error Message ``` Unhandled error: <class 'IndexError'>, list index out of range Traceback (most recent call last): ... File "/home/terravision/.local/lib/python3.12/site-packages/modules/graphmaker.py", line 1457, in handle_variants variant_label = resource.split(".")[1] ~~~~~~~~~~~~~~~~~~~^^^ IndexError: list index out of range ``` ## Context This occurs after successfully parsing HCL and processing 231 resources. The error happens during the "Checking for additional links" phase. The code assumes every resource string will have at least one dot, but some resource identifiers may not follow that pattern. ## Environment - Running via Docker image `patrickchugh/terravision` - Terraform source with Aurora database modules, S3 buckets, KMS keys, and Route53 records ## Suggested Fix Add a guard before the split: ```python # Current (line 1457) variant_label = resource.split(".")[1] # Suggested parts = resource.split(".") variant_label = parts[1] if len(parts) > 1 else resource ```
Author
Owner

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

How is this possible? Every resource in terraform has a resource type and resource name separated by a dot right ? E. G. aws_instance.myec2 ?

<!-- gh-comment-id:4112062122 --> @patrickchugh commented on GitHub (Mar 23, 2026): How is this possible? Every resource in terraform has a resource type and resource name separated by a dot right ? E. G. aws_instance.myec2 ?
Author
Owner

@patrickchugh commented on GitHub (Mar 24, 2026):

@mmclane can you try with the latest version v0.24 and let me know if this can be closed?

<!-- gh-comment-id:4120500462 --> @patrickchugh commented on GitHub (Mar 24, 2026): @mmclane can you try with the latest version v0.24 and let me know if this can be closed?
Author
Owner

@patrickchugh commented on GitHub (Mar 29, 2026):

Closing as no response from OP

<!-- gh-comment-id:4149613380 --> @patrickchugh commented on GitHub (Mar 29, 2026): Closing as no response from OP
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#103
No description provided.