Skip to content

fix: Ensure terraform plan-diff processes yaml and skips init properly - #2305

Merged
Andriy Knysh (aknysh) merged 1 commit into
cloudposse:mainfrom
jhoward-rula:issue-2258/resolve-plan-diff-regression
Apr 9, 2026
Merged

Andriy Knysh (aknysh) merged 1 commit into
cloudposse:mainfrom
jhoward-rula:issue-2258/resolve-plan-diff-regression

Conversation

@jhoward-rula

@jhoward-rula Jon Howard (jhoward-rula) commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

what

why

references

Summary by CodeRabbit

  • New Features
    • The plan-diff command now accepts additional configuration options for controlling Terraform template processing, function execution, and initialization behavior during plan operations.

@jhoward-rula
Jon Howard (jhoward-rula) requested a review from a team as a code owner April 9, 2026 19:46
@atmos-pro

atmos-pro Bot commented Apr 9, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More.

@github-actions github-actions Bot added the size/xs Extra small size PR label Apr 9, 2026
@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The plan-diff command now retrieves Terraform execution control options via ParseTerraformRunOptions() and wires them into the schema.ConfigAndStacksInfo struct, enabling template processing and init-skipping behaviors during plan-diff execution.

Changes

Cohort / File(s) Summary
Terraform Plan-Diff Command
cmd/terraform/plan_diff.go
Added call to ParseTerraformRunOptions(v) to populate ProcessTemplates, ProcessFunctions, and SkipInit fields on the config struct passed to TerraformPlanDiff, enabling proper template rendering and initialization handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

patch

Suggested reviewers

  • aknysh
  • osterman
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: ensuring terraform plan-diff processes YAML templates and respects the skip-init flag, which directly addresses the regression reported in issue #2258.
Linked Issues check ✅ Passed The code changes add ParseTerraformRunOptions to derive ProcessTemplates, ProcessFunctions, and SkipInit fields, directly addressing the regression where templates weren't being rendered during plan-diff operations.
Out of Scope Changes check ✅ Passed All changes are scoped to the plan-diff command initialization, adding the missing template processing and skip-init logic required to fix the regression without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmd/terraform/plan_diff.go (1)

65-67: ⚠️ Potential issue | 🟠 Major

Global config-selection flags can still be ignored at config init.

At Line 66, cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, true) passes an empty struct, which can drop --base-path, --config, --config-path, and --profile selection for this command. Parse global flags first and pass them into InitCliConfig.

Suggested fix.
-		// Initialize Atmos configuration
-		atmosConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, true)
+		// Initialize Atmos configuration with global CLI selection flags.
+		globalInfo := flags.ParseGlobalFlags(cmd, v)
+		atmosConfig, err := cfg.InitCliConfig(globalInfo, true)
 		if err != nil {
 			return err
 		}

Based on learnings: “when initializing CLI config via cfg.InitCliConfig, always first populate ConfigAndStacksInfo with global flag values using flags.ParseGlobalFlags(cmd, v); otherwise --base-path/--config/--config-path/--profile can be ignored.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/terraform/plan_diff.go` around lines 65 - 67, The CLI initializes Atmos
config with an empty schema.ConfigAndStacksInfo which can ignore global flags;
before calling cfg.InitCliConfig in plan_diff.go, parse and populate global flag
values into a ConfigAndStacksInfo instance by calling
flags.ParseGlobalFlags(cmd, v) (or equivalent) and pass that populated struct
into cfg.InitCliConfig(schema.ConfigAndStacksInfo{...}, true); update the code
around cfg.InitCliConfig to create a cfgInfo variable, call
flags.ParseGlobalFlags to fill it, then pass cfgInfo into InitCliConfig so
--base-path/--config/--config-path/--profile are honored.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@cmd/terraform/plan_diff.go`:
- Around line 65-67: The CLI initializes Atmos config with an empty
schema.ConfigAndStacksInfo which can ignore global flags; before calling
cfg.InitCliConfig in plan_diff.go, parse and populate global flag values into a
ConfigAndStacksInfo instance by calling flags.ParseGlobalFlags(cmd, v) (or
equivalent) and pass that populated struct into
cfg.InitCliConfig(schema.ConfigAndStacksInfo{...}, true); update the code around
cfg.InitCliConfig to create a cfgInfo variable, call flags.ParseGlobalFlags to
fill it, then pass cfgInfo into InitCliConfig so
--base-path/--config/--config-path/--profile are honored.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cd10335f-7f5e-466f-8d23-fb9bba8f418d

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8cd16 and 4093e85.

📒 Files selected for processing (1)
  • cmd/terraform/plan_diff.go

@osterman Erik Osterman (Cloud Posse) (osterman) added the patch A minor, backward compatible change label Apr 9, 2026
@codecov

codecov Bot commented Apr 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.18%. Comparing base (5c8cd16) to head (4093e85).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2305      +/-   ##
==========================================
+ Coverage   77.15%   77.18%   +0.02%     
==========================================
  Files        1069     1069              
  Lines      101313   101317       +4     
==========================================
+ Hits        78169    78198      +29     
+ Misses      18834    18809      -25     
  Partials     4310     4310              
Flag Coverage Δ
unittests 77.18% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/terraform/plan_diff.go 68.88% <100.00%> (+3.03%) ⬆️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aknysh Andriy Knysh (aknysh) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@aknysh
Andriy Knysh (aknysh) merged commit 1579fe7 into cloudposse:main Apr 9, 2026
63 of 64 checks passed
@atmos-pro

atmos-pro Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Note

Atmos Pro  

Waiting for your GitHub Actions workflow to upload affected stacks.
Learn More.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.215.0-rc.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/xs Extra small size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

atmos terraform plan-diff specific regression after 1.201.0 in backend/template rendering.

3 participants