mirror of
https://github.com/patrickchugh/terravision.git
synced 2026-05-09 08:25:25 +02:00
[PR #167] [MERGED] fix: Fix KeyError in reverse_relations when handling module resources #187
Labels
No labels
bug
enhancement
enhancement
good first issue
good first issue
good first issue
pipeline
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/terravision#187
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/patrickchugh/terravision/pull/167
Author: @malekmaciej
Created: 2/8/2026
Status: ✅ Merged
Merged: 2/9/2026
Merged by: @patrickchugh
Base:
main← Head:main📝 Commits (1)
3ca467bfix: resolve KeyError when processing Terraform configurations that contain resources defined in submodules with cross-references between module resources and root resources📊 Changes
1 file changed (+4 additions, -1 deletions)
View changed files
📝
modules/graphmaker.py(+4 -1)📄 Description
Fix KeyError in reverse_relations when handling module resources
Problem
Terravision was crashing with a
KeyErrorwhen processing Terraform configurations that contain resources defined in submodules with cross-references between module resources and root resources.Error:
Stack trace:
Root Cause
In the
reverse_relationsfunction (line 354), the code was using the wrong variable name as the dictionary key:The issue is that:
node= resource name without module prefix (e.g.,aws_iam_role.cloudwatch_trigger_ssm_role)n= full resource name with module prefix (e.g.,module.build.aws_iam_role.cloudwatch_trigger_ssm_role)The
graphdictkeys are stored with their full module paths (n), but the code was attempting to access the dictionary using the shortened name (node), causing a KeyError when the resource was defined in a module.Solution
Updated line 352-354 in
modules/graphmaker.pyto:nodetonto match the actual dictionary keyBefore:
After:
Testing
Tested with a Terraform configuration containing:
build/directory)Result: Successfully generated diagram without errors.
Impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.