Skip to content

Fix hide check scoped data sources#38389

Open
Sayeem3051 wants to merge 3 commits intohashicorp:mainfrom
Sayeem3051:fix-hide-check-scoped-data-sources
Open

Fix hide check scoped data sources#38389
Sayeem3051 wants to merge 3 commits intohashicorp:mainfrom
Sayeem3051:fix-hide-check-scoped-data-sources

Conversation

@Sayeem3051
Copy link
Copy Markdown

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.

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
@Sayeem3051 Sayeem3051 requested a review from a team as a code owner April 15, 2026 14:01
@hashicorp-cla-app
Copy link
Copy Markdown

hashicorp-cla-app Bot commented Apr 15, 2026

CLA assistant check
All committers have signed the CLA.

@crw
Copy link
Copy Markdown
Contributor

crw commented Apr 15, 2026

Thanks for this submission. I will raise it in triage.

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.

Data sources within check blocks don't need to be displayed in plan UI

2 participants