Skip to content

fix(terragrunt_providers_lock): Use the updated Terragrunt CLI arguments#940

Closed
yupyvovarov wants to merge 3 commits intoantonbabenko:masterfrom
yupyvovarov:patch-1
Closed

fix(terragrunt_providers_lock): Use the updated Terragrunt CLI arguments#940
yupyvovarov wants to merge 3 commits intoantonbabenko:masterfrom
yupyvovarov:patch-1

Conversation

@yupyvovarov
Copy link
Copy Markdown

Due to an error:

ERROR  The `providers` command is no longer supported. Use `terragrunt run -- providers` instead.

Put an x into the box if that apply:

  • This PR introduces breaking change.
  • This PR fixes a bug.
  • This PR adds new functionality.
  • This PR enhances existing functionality.

Description of your changes

When the hook was running, it failed
зображення

How can we test changes

When it fixed:
зображення

Due to an error:
```
ERROR  The `providers` command is no longer supported. Use `terragrunt run -- providers` instead.
```
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 8, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Restores compatibility of the providers lock workflow with newer Terragrunt versions (0.78+), while remaining compatible with older versions.
    • Ensures accurate exit code propagation from Terragrunt commands.
  • Chores
    • Standardizes subcommand handling for both per-directory and run-all executions to improve reliability.

Walkthrough

Detect Terragrunt version and choose subcommand form: for Terragrunt >= 0.78 use terragrunt run -- providers lock, otherwise use terragrunt providers lock. Update RUN_ALL_SUBCOMMAND accordingly and invoke Terragrunt via the selected SUBCOMMAND while preserving exit code propagation.

Changes

Cohort / File(s) Summary
Terragrunt providers lock hook
hooks/terragrunt_providers_lock.sh
Add SUBCOMMAND array and logic to select run -- providers lock for Terragrunt >= 0.78 or providers lock for older versions; update RUN_ALL_SUBCOMMAND pairing; replace direct invocation with terragrunt "${SUBCOMMAND[@]}" "${args[@]}" and preserve exit code behavior.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Hook as terragrunt_providers_lock.sh
  participant TG as Terragrunt CLI

  Dev->>Hook: Execute hook
  Hook->>TG: terragrunt --version
  TG-->>Hook: Version string
  alt Version >= 0.78
    Hook->>TG: terragrunt run -- providers lock (via SUBCOMMAND)
  else Version < 0.78
    Hook->>TG: terragrunt providers lock (via SUBCOMMAND)
  end
  TG-->>Hook: Exit code
  Hook-->>Dev: Propagate exit code
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

hook/terragrunt_providers_lock

Suggested reviewers

  • antonbabenko
  • yermulnik
  • MaxymVlasov

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title clearly summarises the primary change by identifying the terragrunt_providers_lock hook fix and referencing the updated Terragrunt CLI arguments in a concise conformant style.
Description Check ✅ Passed The pull request description explains the specific error encountered and how the changes address it with illustrative screenshots, demonstrating that it directly relates to the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8f9233 and a09bcc9.

📒 Files selected for processing (1)
  • hooks/terragrunt_providers_lock.sh (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • hooks/terragrunt_providers_lock.sh

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e63792 and e8f9233.

📒 Files selected for processing (1)
  • hooks/terragrunt_providers_lock.sh (1 hunks)
🧰 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_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)

Comment thread hooks/terragrunt_providers_lock.sh Outdated
@yermulnik
Copy link
Copy Markdown
Collaborator

@yupyvovarov Thank you for the contribution. This is already being worked on in scope of #939 though.

@yermulnik yermulnik closed this Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants