Skip to content

Fix #1812: Preserve user's chart path expression instead of resolved absolute path in plan state - #1850

Open
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/1812-chart-path-plan
Open

Fix #1812: Preserve user's chart path expression instead of resolved absolute path in plan state#1850
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/1812-chart-path-plan

Conversation

@dennismdejong

Copy link
Copy Markdown

Description

When using a local directory path for the chart attribute on HCP Terraform Stacks (where plan and apply run in separate ephemeral job directories), Terraform core produces an "inconsistent final plan" error because the planned .chart value contains the absolute path from the plan-time working directory, which differs at apply time.

Root Cause

On HCP Terraform Stacks, Terraform evaluates path.module to an absolute path during plan. This absolute-path value is stored in the plan for the chart attribute. At apply time, path.module resolves to a different directory, causing the inconsistency.

Fix

Added a custom plan modifier (localChartPathPlanModifier) on the chart attribute that:

  1. Detects local chart paths: Only applies to paths that are not URLs or OCI references
  2. Preserves state value: When both the config and state values refer to the same chart identity (same trailing path components), the state value is preserved in the plan
  3. Allows genuine changes: If the user changes the chart to a different path, the config value takes precedence

This ensures the chart path from a previous apply is carried forward when the resolved absolute path differs only due to environment differences (as happens on HCP Terraform Stacks).

@dennismdejong
dennismdejong requested review from a team, iam404 and rigalGit as code owners July 27, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant