Skip to content

fix: skip chartify for build command with dependencies and forceNamespace - #2676

Closed
yxxhero wants to merge 5 commits into
helmfile:mainfrom
yxxhero:fix/build-skip-chartify-deps-1859
Closed

yxxhero wants to merge 5 commits into
helmfile:mainfrom
yxxhero:fix/build-skip-chartify-deps-1859

Conversation

@yxxhero

@yxxhero yxxhero commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #1859

helmfile build fails with repo <repo> not found when releases use dependencies or forceNamespace. This is because build runs with SkipRepos: true (repos not synced), but these release fields trigger chartify which calls helm fetch/helm template.

PR #2212 partially addressed this by filtering releases with jsonPatches, strategicMergePatches, and transformers. This PR completes the fix by also filtering dependencies and forceNamespace, and extends the same fix to status and show-dag, which run chart preparation with the identical SkipRepos: true, SkipDeps: true setup and fail on the same release shapes.

Root Cause

PrintState (build), Status, and PrintDAGState (show-dag) call WithPreparedCharts(..., SkipRepos: true, SkipDeps: true). Since repos are skipped, any chartify trigger that needs remote repo access fails.

In PrepareChartify (helmx.go), 6 conditions set shouldRun = true:

  1. Local dir without Chart.yaml (line 994) — no remote repo needed
  2. Dependencies (line 1038) — needs helm fetch ← was missing
  3. JSONPatches (line 1071) — covered by fix: skip chartify for build command jsonPatches #2212
  4. StrategicMergePatches (line 1085) — covered by fix: skip chartify for build command jsonPatches #2212
  5. Transformers (line 1099) — covered by fix: skip chartify for build command jsonPatches #2212
  6. ForceNamespace (line 1105) — needs helm fetch ← was missing

Changes

  • pkg/state/state.go: Added commandsSkippingChartifyTriggers (build, status, show-dag). Extracted triggersChartifyHelmRun() helper covering all 5 network-dependent chartify triggers; filterReleasesSkippingChartify (formerly filterReleasesForBuild) uses it instead of inline conditions. The local-directory case is intentionally excluded (no remote repo needed).
  • pkg/state/helmx.go: Added a sync note next to shouldRun in PrepareChartify so future chartify triggers are kept in sync with triggersChartifyHelmRun.
  • pkg/app/run.go: WithPreparedCharts now checks map presence instead of comparing the zero value "" against rel.Chart, so a pre-existing ChartPath is no longer wiped for releases skipped by chart preparation.
  • pkg/state/issue_1859_test.go: Unit test with 7 subtests covering each trigger + mixed case, plus a test pinning the command list.
  • pkg/app/app_test.go: Integration tests (TestPrint_WithDependencies, TestStatus_WithChartifyTriggers, TestPrintDAG_WithChartifyTriggers) verifying the full build/status/show-dag flows with deps/forceNamespace/patches/plain releases — correct output, helm status still invoked per release, zero chart-related helm calls.

Verification

E2E tested with proxy (all pass, exit 0):

  • Dependencies (issue helmfile build fail with repo not found when using dependencies #1859 core case)
  • forceNamespace
  • jsonPatches, strategicMergePatches, transformers
  • Combined (deps + FN + patches in one release)
  • All 7 release types in one helmfile
  • helmfile template with deps — no regression (repos synced, chart downloaded)
  • golangci-lint: 0 issues
  • Unit + integration tests pass with -race -p=1

status/show-dag coverage is automated: TestStatus_WithChartifyTriggers and TestPrintDAG_WithChartifyTriggers exercise the full flows with zero chart-related helm calls (any such call panics the mock).

Example

repositories:
  - name: examples
    url: https://helm.github.io/examples

releases:
  - name: hello
    chart: examples/hello-world
    version: 0.1.0
    dependencies:
      - chart: examples/hello-world
        version: 0.1.0

Before: helmfile build → Error: repo examples not found
After: helmfile build → outputs full state successfully

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes helmfile build failures caused by chart preparation invoking chartify/helm operations (e.g., helm fetch / helm template) while the build flow runs with SkipRepos: true, leading to repo <repo> not found for releases that trigger chartify via dependencies or forceNamespace.

Changes:

  • Refactors build-time release filtering in chart preparation to also exclude releases with dependencies and forceNamespace (in addition to the previously handled patch/transformer triggers).
  • Adds a focused unit test covering build filtering behavior across all chartify triggers relevant to issue #1859.
  • Adds an app-level regression test asserting the PrintState / build path performs zero helm calls while still outputting the expected state content.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/state/state.go Adds a helper predicate and extends build-time filtering so chart prep skips additional chartify-triggering releases.
pkg/state/issue_1859_test.go New unit regression test validating filterReleasesForBuild behavior for all relevant triggers.
pkg/app/app_test.go New regression test ensuring PrintState/build makes no helm calls when releases include deps/forceNamespace.

Comment thread pkg/app/app_test.go Outdated
Comment on lines +4585 to +4588
// TestPrint_WithDependencies is a regression test for issue #1859.
// `helmfile build` must not call helm fetch/pull/template for releases
// with dependencies, forceNamespace, jsonPatches, strategicMergePatches,
// or transformers, because build runs with SkipRepos: true.
Comment thread pkg/app/app_test.go
Comment on lines +4628 to +4631
out, err := testutil.CaptureStdout(func() {
err := app.PrintState(configImpl{})
assert.Nil(t, err)
})
Comment thread pkg/state/state.go Outdated
Comment on lines +1478 to +1485
// triggersChartifyRemote mirrors the conditions in PrepareChartify (helmx.go)
// that set shouldRun=true and require network access to fetch or template a
// remote chart. The build command runs with SkipRepos: true, so any release
// matching these conditions fails with "repo not found". The local-directory
// case (NeedsChartifyForLocalDir) is intentionally excluded because it
// operates on a local path and does not require remote repos.
// See issue #1859.
func triggersChartifyRemote(r ReleaseSpec) bool {

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

yxxhero added 2 commits July 12, 2026 11:06
…pace (helmfile#1859)

The build command is read-only and runs with SkipRepos: true, meaning
repositories are not synced. However, releases with dependencies or
forceNamespace trigger chartify (PrepareChartify in helmx.go), which
runs helm fetch/pull/template and requires repos — causing
"repo <repo> not found" errors.

PR helmfile#2212 partially addressed this by filtering releases with jsonPatches,
strategicMergePatches, and transformers. This change extends the filter
to also cover dependencies and forceNamespace, completing the fix for
issue helmfile#1859.

The filter is refactored into triggersChartifyRemote() which mirrors all
conditions in PrepareChartify that set shouldRun=true and require network
access. The local-directory case (NeedsChartifyForLocalDir) is excluded
as it operates on local paths without needing remote repos.

Signed-off-by: yxxhero <[email protected]>
Signed-off-by: yxxhero <[email protected]>
@yxxhero
yxxhero force-pushed the fix/build-skip-chartify-deps-1859 branch from e45695a to 48cd43c Compare July 12, 2026 03:07
@stale

stale Bot commented Jul 26, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Jul 26, 2026
@yxxhero yxxhero removed the wontfix This will not be worked on label Jul 27, 2026
@stale

stale Bot commented Aug 14, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Aug 14, 2026
@yxxhero yxxhero removed the wontfix This will not be worked on label Aug 15, 2026
@stale

stale Bot commented Aug 29, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Aug 29, 2026
@yxxhero yxxhero removed the wontfix This will not be worked on label Aug 29, 2026
@stale

stale Bot commented Sep 13, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Sep 13, 2026
@yxxhero yxxhero removed the wontfix This will not be worked on label Sep 13, 2026
yxxhero and others added 3 commits September 15, 2026 21:43
- Extend the chartify-trigger release filter beyond `build` to `status`
  and `show-dag`: these read-only commands run chart preparation with
  SkipRepos/SkipDeps and fail with "repo not found" on the same release
  shapes (dependencies, forceNamespace, patches, transformers).
- Generalize naming: filterReleasesForBuild ->
  filterReleasesSkippingChartify, gated by the new
  commandsSkippingChartifyTriggers list; fix the stale call-site comment.
- Add a sync note in PrepareChartify (helmx.go) next to `shouldRun` so
  future chartify triggers stay in sync with triggersChartifyHelmRun.
- WithPreparedCharts: check map presence instead of comparing the zero
  value against rel.Chart, so a pre-existing ChartPath is no longer
  wiped for releases skipped by chart preparation.
- Tests: pin the command list (TestCommandsSkippingChartifyTriggers);
  add end-to-end regression tests for show-dag and status; assert that
  build output leaks no chartPath/chartify temp paths.

Signed-off-by: yxxhero <[email protected]>
Signed-off-by: yxxhero <[email protected]>

# Conflicts:
#	pkg/app/run.go
@stale

stale Bot commented Oct 3, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Oct 3, 2026
@yxxhero yxxhero removed the wontfix This will not be worked on label Oct 3, 2026
@stale

stale Bot commented Oct 17, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Oct 17, 2026
@yxxhero yxxhero removed the wontfix This will not be worked on label Oct 17, 2026
@stale

stale Bot commented Oct 31, 2026

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Oct 31, 2026
@stale stale Bot closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helmfile build fail with repo not found when using dependencies

2 participants