Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix diagnostic & avoid variable override via environment #36435

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

radeksimko
Copy link
Member

@radeksimko radeksimko commented Feb 5, 2025

Fixes #36410

It turns out the ordering of variable source evaluation is correct, it's just the diagnostic message that is wrong due to mixed ordering of arguments to fmt.Sprintf.

While the original report in #36410 suggests overriding variables via environment variables to be silently ignored, I think we cannot just make the same argument as was made in #36180

Specifically - We cannot expect users to be deleting autoloadable tfvars files. I do think it's reasonable to expect them to unset environment variables between plan and apply. Also, more importantly we only raise the diagnostic when values differ anyway.

That said after some consideration I chose to propose a warning that is still somewhat ignorable, just possibly noisy. I believe that is a good compromise that will not break workflows but still highlight what we consider anti-pattern.

Target Release

1.11.x

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@radeksimko radeksimko force-pushed the b-avoid-var-override-via-env branch from 7f3699d to 7a52518 Compare February 5, 2025 16:05
@radeksimko radeksimko force-pushed the b-avoid-var-override-via-env branch 3 times, most recently from e2959c5 to 3c3d096 Compare February 5, 2025 16:23
@radeksimko radeksimko added 1.10-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged 1.11-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged labels Feb 5, 2025
@radeksimko radeksimko force-pushed the b-avoid-var-override-via-env branch from 3c3d096 to e73ac99 Compare February 5, 2025 16:25
@radeksimko radeksimko marked this pull request as ready for review February 5, 2025 16:38
@radeksimko radeksimko requested a review from a team as a code owner February 5, 2025 16:38
Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

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

I think this is going to be OK, and will help users going forward, but we should still be on the lookout for any existing workflows which might be impacted.

@jbardin
Copy link
Member

jbardin commented Feb 5, 2025

I don't think we're planning on any more v1.10 releases, so we might not want that backport label

@radeksimko radeksimko removed the 1.10-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Feb 5, 2025
@radeksimko
Copy link
Member Author

I don't think we're planning on any more v1.10 releases, so we might not want that backport label

I don't have strong opinion but I assume that it's technically a regression, i.e. this worked fine in 1.9 and we (using your words 😄) broke it in 1.10 so I also concluded it would be good to fix that.

We could also nudge people to upgrade I guess but we have not even cut a final 1.11 yet.

Either way the backport can be sorted out post-merge.

@radeksimko radeksimko merged commit 70a1fd5 into main Feb 5, 2025
19 checks passed
@radeksimko radeksimko deleted the b-avoid-var-override-via-env branch February 5, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.11-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Variables values get overridden from environment variables when applying a plan
2 participants