-
-
Notifications
You must be signed in to change notification settings - Fork 113
fix: Support valid Terragrunt tfr:/// format in autodiscovery #7357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
olblak
merged 5 commits into
updatecli:main
from
eugenestarchenko:fix/terragrunt-tfr-triple-slash
Jan 1, 2026
Merged
fix: Support valid Terragrunt tfr:/// format in autodiscovery #7357
olblak
merged 5 commits into
updatecli:main
from
eugenestarchenko:fix/terragrunt-tfr-triple-slash
Jan 1, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes parsing of Terragrunt module sources using the tfr:/// (triple slash) format, which is the valid Terragrunt syntax for default registry. The current implementation fails on tfr:/// because it constructs baseUrl with a leading slash (/terraform-aws-modules/eks/aws) which ParseModuleSource rejects. URL format: protocol://hostname/path - tfr:///namespace/name/target → Host="", Path="/namespace/name/target" - tfr://registry.io/namespace/name/target → Host="registry.io", Path="/namespace/name/target" - tfr://namespace/name/target → Host="namespace", Path="/name/target" The 2-slash format (tfr://terraform-aws-modules/...) works in Updatecli's parser by accident but FAILS in actual Terragrunt with "lookup terraform-aws-modules: no such host" because it treats the namespace as a hostname. This fix strips the leading slash and correctly handles all valid formats.
Update all test files and test expectations to use the valid tfr:/// (triple slash) format instead of the invalid tfr:// (two slash) format. Changes: - testdata/*.hcl: Updated module sources to tfr:/// - main_test.go: Updated expected manifest outputs - matching_rule_test.go: Updated test cases and assertions - matching_rule.go: Updated documentation example
9585e1e to
d6836f3
Compare
The matching rule code strips 'tfr://' from patterns, leaving an extra slash when the pattern is 'tfr:///'. This causes invalid wildcard URLs like 'tfr:////updatecliswildcard'. Add TrimPrefix to remove the leading slash after stripping the protocol, ensuring correct token counting for wildcard expansion. Also update utils_test.go expectations to use tfr:/// format.
Contributor
Author
|
Hi @olblak how does that look to you? |
andreyreshetnikov-zh
approved these changes
Dec 31, 2025
Member
|
Thanks @eugenestarchenko for the pull request. |
Member
|
Thanks for the pull request, it looks great to me especially with the test I'll merge it once done |
olblak
previously approved these changes
Jan 1, 2026
Contributor
Author
done |
olblak
approved these changes
Jan 1, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Terragrunt's valid
tfr:///(triple slash) format fails in autodiscovery with:Root Cause
Both the parser and matching rule code strip
tfr://from URLs, but this leaves a leading slash when the format istfr:///:Example:
tfr:///terraform-aws-modules/eks/awstfr://:/terraform-aws-modules/eks/awsIn matching rules with wildcards:
tfr:///(match all registry modules)tfr://:/remainstfr:////updatecliswildcard/updatecliswildcard/updatecliswildcardWhy not use 2 slash format?
The test suite uses
tfr://terraform-aws-modules/...(2 slashes), which works in Updatecli but fails in actual Terragrunt:Per URL spec
protocol://hostname/path, the 2-slash format treatsterraform-aws-modulesas a hostname, causing DNS lookup failures.Valid Terragrunt formats:
tfr:///terraform-aws-modules/eks/aws(3 slashes = empty hostname → defaults to registry.terraform.io)tfr://registry.terraform.io/terraform-aws-modules/eks/aws(explicit registry)Invalid in Terragrunt:
tfr://terraform-aws-modules/eks/aws(2 slashes = namespace treated as hostname)See https://terragrunt.gruntwork.io/docs/reference/hcl/blocks/#terraform
Result
All valid Terragrunt formats now work:
Testing
Verified with real Terragrunt module: