mirror of
https://github.com/patrickchugh/terravision.git
synced 2026-05-09 08:25:25 +02:00
[PR #164] [MERGED] Fix FileNotFoundError for modules with subdirectory notation (//) #186
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#186
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/164
Author: @j-srodka
Created: 1/28/2026
Status: ✅ Merged
Merged: 2/7/2026
Merged by: @patrickchugh
Base:
main← Head:fix/subdirectory-notation-support📝 Commits (2)
fbc1e2bFix FileNotFoundError for modules with subdirectory notation (//)5303d61Fix module cache issue and enhance URL parsing for all source types📊 Changes
1 file changed (+40 additions, -12 deletions)
View changed files
📝
modules/gitlibs.py(+40 -12)📄 Description
Pull Request: Fix FileNotFoundError for modules with subdirectory notation (//)
Description
This PR fixes issue #163 where Terravision crashes with
FileNotFoundErrorwhen processing Terraform modules that use the//subdirectory notation.Updates (v2): Enhanced fix to address additional feedback:
git::prefixed URLsProblem
When processing modules like
terraform-aws-modules/ecs/aws//modules/cluster, Terravision had two issues:FileNotFoundErrorExample of the Bug:
Input:
terraform-aws-modules/ecs/aws//modules/clusterCurrent (incorrect) behavior:
terraform-aws-modules_ecs_aws__modules_cluster;module_name;terraform-aws-modules_ecs_aws__modules_cluster;module_name;/clusterExpected behavior:
terraform-aws-modules_ecs_aws;module_name;terraform-aws-modules_ecs_aws;module_name;/modules/clusterChanges Made
1. Enhanced
clone_files()function - Base URL extractionOriginal issue: Simple
split("//")incorrectly parsed URLs with protocols (e.g.,git::https://split at protocol's//)Fix: Added intelligent URL parsing that handles:
git::https://github.com/repo.git//subfoldergit::prefixhttps://)//https://github.com/repo.git//subfolderhttps:////only in remaining partterraform-aws-modules/ecs/aws//modules/cluster//(no protocol to avoid)2. Fixed cache behavior for main modules
Original issue: Cache check had
and module != "main"preventing main source cachingFix: Removed condition so ALL modules (including "main") use cache on subsequent runs
3. Updated
_handle_cached_module()functionsubfolderparameter to function signatureImpact
This fix affects any Terraform configuration using modules with subdirectory notation:
terraform-aws-modules/ecs/aws//modules/clustergit::https://github.com/example/repo.git//path/to/modulegit::ssh://git@github.com/example/repo.git//path/to/modulehttps://github.com/example/repo.git//path/to/modulegithub.com/example/repo//path/to/moduleThis is a very common pattern, especially with official
terraform-aws-modulescollections.Testing
Test 1: Maintainer's example
Source:
https://github.com/patrickchugh/testcase-bastion.git//examplesTest 2: Registry modules with subdirectories
Tested with real-world Terraform configurations:
terraform-aws-modules/ecs/aws//modules/cluster✅terraform-aws-modules/ecs/aws//modules/service✅terraform-aws-modules/route53/aws//modules/records✅terraform-aws-modules/cloudwatch/aws//modules/log-metric-filter✅All modules were successfully processed without
FileNotFoundError.Test 3: git:: prefixed URLs
git::https://github.com/terraform-aws-modules/terraform-aws-vpc.git//examples/simple-vpcTest 4: Local testing
Successfully tested locally on macOS (darwin_arm64) with:
Backwards Compatibility
✅ This change is fully backwards compatible:
//work exactly as beforeFiles Changed
modules/gitlibs.py: Fixed path handling for subdirectory notationCloses #163
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.