Fix hide check scoped data sources#38389
Open
Sayeem3051 wants to merge 3 commits intohashicorp:mainfrom
Open
Conversation
Fixes hashicorp#36536 This change skips rendering data sources in the plan output when they are being reloaded solely for check block verification (check blocks). These data sources have no actionable diff - the Action is Read with ActionReason ReadBecauseCheckNested - and showing them with an empty block in the plan output is confusing to users. The fix adds a condition in renderHumanDiff (internal/command/jsonformat/plan.go) to return early for data sources where: - Mode == DataResourceMode - ActionReason == ResourceInstanceReadBecauseCheckNested - Action == Read This is consistent with how the existing code already handles NoOp changes and deleted data sources. 🤖🤖🤖
…anges The previous fix returned early from renderHumanDiff for check-scoped data sources, but the counts[plans.Read] had already been incremented in renderHuman. This caused willPrintResourceChanges to be set to true and the "Terraform will perform the following actions:" header to be printed, even though no resources were shown. This fix adds the same skip condition earlier in renderHuman, before changes are appended to the list and before counts are incremented. This ensures check-scoped data sources are completely filtered out at the source, matching the behavior of the deleted data sources check. The defensive check in renderHumanDiff is kept as a safety net for other callers like renderHumanDiffDrift. Fixes hashicorp#36536
Contributor
|
Thanks for this submission. I will raise it in triage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix hide check scoped data sources
This change skips rendering data sources in the plan output when they are being reloaded solely for check block verification (check blocks). These data sources have no actionable diff - the Action is Read with ActionReason ReadBecauseCheckNested - and showing them with an empty block in the plan output is confusing to users.
The fix adds conditions in both renderHuman and renderHumanDiff (internal/command/jsonformat/plan.go) to skip check-scoped data sources before they are rendered or counted in the plan output.
Fixes #36536
Target Release
1.16.x
Rollback Plan
[x] If a change needs to be reverted, we will roll out an update to the code within 7 days.
Changes to Security Controls
No changes to security controls.
CHANGELOG entry
[x] This change is user-facing and I added a changelog entry.
[ ] This change is not user-facing.