Skip to content

Fix crash on empty helm render: treat no-output chart as no-op - #207

Draft
yxxhero with Copilot wants to merge 2 commits into
masterfrom
copilot/chartify-crashes-on-empty-render
Draft

Fix crash on empty helm render: treat no-output chart as no-op#207
yxxhero with Copilot wants to merge 2 commits into
masterfrom
copilot/chartify-crashes-on-empty-render

Conversation

Copilot AI commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

When all chart templates are gated behind a falsy conditional, helm template --output-dir produces an empty directory. ReplaceWithRendered then crashed with an opaque assertion error because it expected exactly one subdirectory in the output dir.

Changes

  • replace.go: After reading helmOutputDirEntries, if the slice is empty, remove the chart's content dirs (templates/, charts/, crds/) so subsequent helm processing also sees no resources, clean up the temp output dir, and return nil, nil (empty file list, no error). This is a no-op from the caller's perspective.

  • testdata/charts/emptychart/: Minimal test chart with a ConfigMap template fully gated behind {{- if .Values.enabled }} (default: false).

  • integration_test.go: New "empty render no op" integration test exercising this path via OverrideNamespace (which forces ReplaceWithRendered to be called).

Example

# templates/configmap.yaml — renders nothing by default
{{- if .Values.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-cm
{{- end }}

Previously, running chartify against such a chart (with any of OverrideNamespace, JsonPatches, StrategicMergePatches, or Transformers configured) would crash:

assertion failed: unexpected dir entry "" it must be the abs path to the output directory

After this fix, chartify returns successfully with an empty resource list.

When helm template --output-dir produces an empty directory (e.g. all
templates are gated behind a falsy conditional), ReplaceWithRendered
now removes the chart's content dirs and returns successfully with an
empty file list instead of crashing with an assertion error.

Adds test chart testdata/charts/emptychart and integration test
'empty render no op' to cover this scenario.

Closes #206
Copilot AI changed the title [WIP] Fix chartify crash on empty render Fix crash on empty helm render: treat no-output chart as no-op Aug 1, 2026
Copilot AI requested a review from yxxhero August 1, 2026 00:17
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.

chartify crashes on empty render: expose sentinel error or treat as no-op

2 participants