Skip to content

Fix broken terragrunt stack output functionality and tests#1578

Merged
james00012 merged 2 commits intomainfrom
fix-terragrunt-stack-output
Aug 5, 2025
Merged

Fix broken terragrunt stack output functionality and tests#1578
james00012 merged 2 commits intomainfrom
fix-terragrunt-stack-output

Conversation

@james00012
Copy link
Copy Markdown
Contributor

Summary

This PR fixes the broken terragrunt stack output functionality by ensuring the output subcommand doesn't use the -- separator, which was causing empty output and failing tests.

Problem

The terragrunt stack output command was incorrectly using the -- separator, which is only needed for the run subcommand. This caused:

  • Empty output from terragrunt stack output commands
  • Failing tests in TestTgOutputIntegration and TestTgOutputErrorHandling
  • Incorrect command syntax: terragrunt stack output -- -no-color mother instead of terragrunt stack output -no-color mother

Solution

  • Updated runTerragruntStackSubCommandE to only add -- separator for run subcommand
  • Refactored TgOutputE and TgOutputJsonE to use the shared command execution logic
  • Added proper output cleaning functions to extract values from terragrunt's verbose output
  • Fixed tests to work with the corrected implementation

Changes

  • Modified command execution logic in runTerragruntStackSubCommandE
  • Implemented proper stack output functions with cleaning logic
  • Updated tests to match the new implementation
  • Added all necessary stack-related files from the feature branch

Test plan

  • All terragrunt stack output tests pass
  • TestTgOutputIntegration - tests basic output functionality
  • TestTgOutputErrorHandling - tests error cases
  • All terragrunt module tests pass

@james00012 james00012 force-pushed the fix-terragrunt-stack-output branch 5 times, most recently from 96c28cd to 0e88f19 Compare July 28, 2025 01:29
The terragrunt stack output commands were failing because runTerragruntStackCommandE was adding a "--" separator that the output subcommand doesn't support. This commit fixes the issue by adding a new function that allows callers to control whether the separator is used.

Changes:
- Add runTerragruntStackCommandWithSeparatorE that accepts a useArgSeparator parameter
- Update runTerragruntStackCommandE to call the new function with useArgSeparator=true for backward compatibility
- Update TgOutputE and TgOutputJsonE to call runTerragruntStackCommandWithSeparatorE with useArgSeparator=false

The output command has different argument handling than other stack subcommands (like run) and cannot use the -- separator.
@james00012 james00012 force-pushed the fix-terragrunt-stack-output branch from 0e88f19 to ed5147e Compare July 28, 2025 01:33
@james00012 james00012 merged commit 22239bc into main Aug 5, 2025
2 of 3 checks passed
@james00012 james00012 deleted the fix-terragrunt-stack-output branch August 5, 2025 23:19
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