Skip to content

Fix chartify assertion failure when rendered chart output is empty (Issue #1757) - #2306

Closed
ljluestc wants to merge 1 commit into
helmfile:mainfrom
ljluestc:main
Closed

ljluestc wants to merge 1 commit into
helmfile:mainfrom
ljluestc:main

Conversation

@ljluestc

Copy link
Copy Markdown

Helmfile fails with an assertion error when using transformers, jsonPatches, or strategicMergePatches on a Helm chart that renders no resources. The error occurs because the chartify library expects output files to exist, but when helm template produces no output (e.g., when a chart is conditionally disabled), the chartify process fails with:

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

Root Cause

The issue happens in the processChartification function in pkg/state/state.go. When a chart renders no resources but has chartification operations configured, chartify attempts to process an empty output directory, triggering an assertion failure.

Solution

Added error handling to detect the specific chartify assertion error and treat it as a no-op operation. When this error occurs:

  1. Log a debug message indicating empty output was received
  2. Return the original chart path without modification
  3. Continue processing without error

Changes Made

1. Fixed pkg/state/state.go

  • Added error handling after c.Chartify() call
  • Detects the specific assertion error message
  • Returns early with the original chart path when detected
out, err := c.Chartify(release.Name, chartPath, chartify.WithChartifyOpts(chartifyOpts))
if err != nil {
    // Work around chartify failing when the rendered chart output is empty but
    // jsonPatches / strategicMergePatches / transformers are configured.
    // See https://github.com/helmfile/helmfile/issues/1757
    if strings.Contains(err.Error(), `unexpected dir entry "" it must be the abs path to the output directory`) {
        st.logger.Debugf("Chartify returned empty output for release %s, treating as no-op chartification", release.Name)
        return chartPath, false, nil
    }
    return "", false, err
}

2. Added Comprehensive Tests in pkg/state/issue_1757_test.go

  • TestIssue1757: Tests with transformers configuration
  • TestIssue1757_JSONPatches: Tests with jsonPatches configuration
  • Both tests create charts that render no resources but have chartification operations
  • Verifies that PrepareCharts completes successfully without errors

Test Coverage

The tests cover scenarios where:

  • A Helm chart has enabled: false in values, producing empty template output
  • Chartification operations (transformers or jsonPatches) are configured
  • The chartify assertion error would have occurred
  • Helmfile now handles the situation gracefully

Backward Compatibility

This change is fully backward compatible:

  • Normal chartification operations continue to work as before
  • Only the specific assertion error case is handled differently
  • No changes to existing behavior for charts with non-empty output

Verification

Run the following to verify the fix:

go test -v ./pkg/state -run TestIssue1757

Both test cases should pass, confirming that the issue is resolved for both transformers and JSONPatches scenarios.

Related Issues

@yxxhero

yxxhero commented Nov 30, 2025

Copy link
Copy Markdown
Member

@ljluestc please fix DCO issue.

@stale

stale Bot commented Dec 14, 2025

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 Dec 14, 2025
@stale stale Bot closed this Dec 21, 2025
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.

Failed to apply transformers if rendered Helm chart is empty

2 participants