From f5a8a6a9017f336f3a4a73465b0fa786a9a2c689 Mon Sep 17 00:00:00 2001 From: Abkari Mohammed Sayeem <169171880+Sayeem3051@users.noreply.github.com> Date: Tue, 14 Apr 2026 22:50:27 +0530 Subject: [PATCH 1/3] command/jsonformat: hide check-scoped data sources from plan output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #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. 🤖🤖🤖 --- internal/command/jsonformat/plan.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/command/jsonformat/plan.go b/internal/command/jsonformat/plan.go index e1f54aa3457a..372330cd1c18 100644 --- a/internal/command/jsonformat/plan.go +++ b/internal/command/jsonformat/plan.go @@ -395,6 +395,13 @@ func renderHumanDiff(renderer Renderer, diff diff, cause string) (string, bool) // Skip resource changes that have nothing interesting to say. return "", false } + // Skip data sources that are reloaded only for check block verification + if diff.change.Mode == jsonstate.DataResourceMode && + diff.change.ActionReason == jsonplan.ResourceInstanceReadBecauseCheckNested && + action == plans.Read { + return "", false + } + var buf bytes.Buffer buf.WriteString(renderer.Colorize.Color(resourceChangeComment(diff.change, action, cause))) From 58a9196687c3e8fe879285e370856808db42e3b9 Mon Sep 17 00:00:00 2001 From: Abkari Mohammed Sayeem <169171880+Sayeem3051@users.noreply.github.com> Date: Tue, 14 Apr 2026 22:58:31 +0530 Subject: [PATCH 2/3] Add bug fix entry for hiding check-scoped data sources --- .changes/v1.16/BUG FIXES-20260414-120000.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/v1.16/BUG FIXES-20260414-120000.yaml diff --git a/.changes/v1.16/BUG FIXES-20260414-120000.yaml b/.changes/v1.16/BUG FIXES-20260414-120000.yaml new file mode 100644 index 000000000000..af00dfd14d74 --- /dev/null +++ b/.changes/v1.16/BUG FIXES-20260414-120000.yaml @@ -0,0 +1,5 @@ +kind: BUG FIXES +body: hide check-scoped data sources from plan output +time: 2026-04-14T12:00:00.000000-04:00 +custom: + Issue: "36536" From 9e3dd04e3543b01effa395083f57fd0f514c27db Mon Sep 17 00:00:00 2001 From: Abkari Mohammed Sayeem <169171880+Sayeem3051@users.noreply.github.com> Date: Tue, 14 Apr 2026 23:08:57 +0530 Subject: [PATCH 3/3] command/jsonformat: skip check-scoped data sources before counting changes 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/terraform#36536 --- internal/command/jsonformat/plan.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/command/jsonformat/plan.go b/internal/command/jsonformat/plan.go index 372330cd1c18..609e0d82d1c5 100644 --- a/internal/command/jsonformat/plan.go +++ b/internal/command/jsonformat/plan.go @@ -77,6 +77,11 @@ func (plan Plan) renderHuman(renderer Renderer, mode plans.Mode, opts ...plans.Q // Don't render anything for deleted data sources. continue } + // Skip data sources that are reloaded only for check block verification + if action == plans.Read && diff.change.Mode == jsonstate.DataResourceMode && + diff.change.ActionReason == jsonplan.ResourceInstanceReadBecauseCheckNested { + continue + } changes = append(changes, diff)