fix(terragrunt_providers_lock, terragrunt_validate: Properly handle arguments passed from terragrunt to TF#939
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughPer-dir hook logic now chooses a version-aware Terragrunt subcommand: for Terragrunt >= 0.78 it uses the Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Hook as Hook script
participant TG as terragrunt
Hook->>Hook: Check terragrunt version
alt terragrunt >= 0.78
Note right of Hook#DDEBF7: Use "run --" subcommand form
Hook->>TG: terragrunt run -- <command> "${args[@]}"
TG-->>Hook: exit (status)
else terragrunt < 0.78
Note right of Hook#F7E6D6: Use legacy subcommand form
Hook->>TG: terragrunt <command> "${args[@]}"
TG-->>Hook: exit (status)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull Request Overview
Updates the terragrunt providers lock hook to use conditional command execution based on Terragrunt version, supporting both legacy and new command structures.
- Introduces version-based conditional logic to handle Terragrunt version differences
- Adds support for new
run --allcommand structure for Terragrunt 0.78+ - Maintains backward compatibility with older Terragrunt versions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
hooks/terragrunt_providers_lock.sh(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-13T19:34:00.317Z
Learnt from: jannis-a
PR: antonbabenko/pre-commit-terraform#933
File: hooks/terragrunt_providers_lock.sh:18-21
Timestamp: 2025-09-13T19:34:00.317Z
Learning: In terragrunt hooks, the `--` separator should only be added before Terraform commands that are invoked through Terragrunt (like `providers lock`, `validate`), but not before native Terragrunt commands (like `hcl validate`). The separator tells Terragrunt to pass subsequent arguments to the underlying Terraform command, which is not applicable for Terragrunt's own commands.
Applied to files:
hooks/terragrunt_providers_lock.sh
🧬 Code graph analysis (1)
hooks/terragrunt_providers_lock.sh (1)
hooks/_common.sh (1)
common::terragrunt_version_ge_0.78(622-639)
🔇 Additional comments (1)
hooks/terragrunt_providers_lock.sh (1)
17-21: LGTM: Version-based command setup is correct.The version-dependent initialization of
RUN_ALL_SUBCOMMANDproperly distinguishes between the newrun --allsyntax (>= 0.78) and the legacyrun-allsyntax. This array is correctly consumed byrun_hook_on_whole_repoat line 76.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Thank you for the contribution.
I think it is best to follow the pattern already established for run --all (and implemented in e.g. terragrunt_validate_inputs.sh). For this, could you please update main function to have the below:
if common::terragrunt_version_ge_0.78; then
local -ra SUBCOMMAND=(run -- providers lock)
local -ra RUN_ALL_SUBCOMMAND=(run --all -- providers lock)
else
local -ra SUBCOMMAND=(providers lock)
local -ra RUN_ALL_SUBCOMMAND=(run-all providers lock)
fiAnd then just re-use in per_dir_hook_unique_part function instead of adding new if-conditional:
terragrunt "${SUBCOMMAND[@]}" "${args[@]}"Does this sound reasonable to you?
The terragrunt_validate.sh seems to need the same update. WDYT will you be up to update it too please?
Co-authored-by: George Yermulnik (Georgii Iermulnik) <yz@yz.kiev.ua>
@ajax-kovtunov-o I can see you pushed the change and requested review, though I can't seem to see the change I suggested in the above quoted comment — is there a reason behind it? Thanks. |
Let me know and I can push changes to your branch (you'll only need to allow us to push — see screenshot below): |
|
@yermulnik check |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
hooks/terragrunt_providers_lock.sh(2 hunks)hooks/terragrunt_validate.sh(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- hooks/terragrunt_providers_lock.sh
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: jannis-a
PR: antonbabenko/pre-commit-terraform#933
File: hooks/terragrunt_providers_lock.sh:18-21
Timestamp: 2025-09-13T19:34:00.317Z
Learning: In terragrunt hooks, the `--` separator should only be added before Terraform commands that are invoked through Terragrunt (like `providers lock`, `validate`), but not before native Terragrunt commands (like `hcl validate`). The separator tells Terragrunt to pass subsequent arguments to the underlying Terraform command, which is not applicable for Terragrunt's own commands.
📚 Learning: 2025-09-13T19:34:00.317Z
Learnt from: jannis-a
PR: antonbabenko/pre-commit-terraform#933
File: hooks/terragrunt_providers_lock.sh:18-21
Timestamp: 2025-09-13T19:34:00.317Z
Learning: In terragrunt hooks, the `--` separator should only be added before Terraform commands that are invoked through Terragrunt (like `providers lock`, `validate`), but not before native Terragrunt commands (like `hcl validate`). The separator tells Terragrunt to pass subsequent arguments to the underlying Terraform command, which is not applicable for Terragrunt's own commands.
Applied to files:
hooks/terragrunt_validate.sh
|
@yermulnik if you want perform any edits - you permitted to do |
yermulnik
left a comment
There was a problem hiding this comment.
LGTM. Thank you.
@MaxymVlasov Please review.
Sounds great. Appreciate it. |
|
@yermulnik, when can I expect the merge and release of the changes? If it won't be released soon, we may face the necessity to downgrade the terragrunt version. |
Let me check with @MaxymVlasov |
terragrunt_providers_lock, terragrunt_validate: Properly handle arguments passed from terragrunt to TF
…arguments passed from terragrunt to TF (#939)
…dle arguments passed from terragrunt to TF (#939)
## [1.101.1](v1.101.0...v1.101.1) (2025-10-09) ### Bug Fixes * **`terragrunt_providers_lock`, `terragrunt_validate`:** Properly handle arguments passed from terragrunt to TF ([#939](#939)) ([bae0525](bae0525))
|
This PR is included in version 1.101.1 🎉 |



Put an
xinto the box if that apply:Description of your changes
How can we test changes