From 6673ebad843643dd312359a00002eddfa3a59883 Mon Sep 17 00:00:00 2001 From: Shane Starcher Date: Sat, 4 Oct 2025 18:39:54 -0500 Subject: [PATCH] fix: skip chartify for build command jsonPatches (#2212) The build command is intended to be a read-only inspection command that outputs the helmfile state. However, when releases use jsonPatches, strategicMergePatches, or transformers, the chart preparation step triggers chartify, which runs helm template and requires dependencies to be built. This causes two issues: 1. helm template is executed unnecessarily for a simple state inspection 2. Missing chart dependencies cause errors even with SkipDeps enabled This change modifies PrepareCharts to filter out releases that require chartify when the command is "build". These releases are excluded from chart preparation, preventing helm template from being invoked. The state output will still include these releases, but their charts won't be processed during the build operation. Signed-off-by: Shane Starcher --- pkg/state/state.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkg/state/state.go b/pkg/state/state.go index af26d017..2d5a7fed 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -1139,6 +1139,16 @@ func releasesNeedCharts(releases []ReleaseSpec) []ReleaseSpec { return result } +func filterReleasesForBuild(releases []ReleaseSpec) []ReleaseSpec { + var filteredReleases []ReleaseSpec + for _, r := range releases { + if len(r.JSONPatches) == 0 && len(r.StrategicMergePatches) == 0 && len(r.Transformers) == 0 { + filteredReleases = append(filteredReleases, r) + } + } + return filteredReleases +} + type ChartPrepareOptions struct { ForceDownload bool SkipRepos bool @@ -1237,6 +1247,12 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre releases := releasesNeedCharts(selected) + // For build command, skip releases that require chartify (jsonPatches, etc.) + // as we only need to output state, not actually template the charts + if helmfileCommand == "build" { + releases = filterReleasesForBuild(releases) + } + var prepareChartInfoMutex sync.Mutex prepareChartInfo := make(map[PrepareChartKey]string, len(releases))