Repository navigation
fix: resolve duplicate helm plugin conflict when auto-init is enabled - #726
Merged
Merged
Conversation
When helmfile-auto-init is combined with helm-plugins, helmfile init installs plugins (e.g. "diff") into a repo-named directory (helm-diff/), and the action's Helm v4 .tgz install path extracts the same plugin into an asset-named directory (helm-diff-OS-ARCH/). Both directories declare the same plugin name, so helm plugin list fails with: two plugins claim the name "diff" at ".../helm-diff" and ".../helm-diff-macos-arm64" This broke the test-action-auto-init job on macOS/Windows. Detect the duplicate-name conflict (reported by Helm on stderr even when the install exits 0) and remove the directory created from the .tgz asset, treating the plugin as already installed. Fixes the CI failure on #720.
On Windows, `helm plugin install` exits 0 and does NOT report the duplicate-name conflict on stderr (the conflict only surfaces later at `helm plugin list`). So the stderr-based detection from the previous commit missed Windows, and test-action-auto-init still failed there. Add a directory-based verification: after a successful .tgz install, read the just-created directory's declared plugin name and check sibling directories for the same name. If a pre-existing plugin already claims that name, remove the directory we just created from the .tgz asset. Also add a regression test for the Windows-style silent-duplicate case.
The Basic validation workflow runs `npm audit --audit-level=high`, which failed on the undici advisory (undici <=6.26.0, high severity) pulled in transitively via @actions/http-client. Bump the lockfile entry from 6.24.1 to 6.27.0 (still within the ^6.23.0 range) to resolve it. This is a non-breaking change. This was also failing on main.
…sed path Post-review cleanup: - Remove the stderr-based duplicate classification (isDuplicatePluginError and the 'duplicate' branch). It was redundant with the directory-based removeDuplicateAssetInstall() check, which is OS-independent and runs on every successful install. Helm does not report the conflict consistently during install (silent on Windows), so the directory check is the single source of truth. - Unify the duplicate log message to "removed duplicate directory" (previously "removing" in the stderr path vs "removed" in the dir path). - Consolidate the two duplicate tests into one that exercises the shared path, with precise mockResolvedValueOnce sequencing. - Add an explicit negative assertion (mockRm not called) on a clean install to guard against accidental deletion of legit plugin directories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
test-action-auto-initjob inbasic-validation.ymlis failing on macOS and Windows (see PR #720 CI):Root cause
When
helmfile-auto-init: trueis combined withhelm-plugins:helmfile init --forceinstalls thediffplugin into a repo-named directory:helm-diff/.tgzinstall path resolves and installs the platform assethelm-diff-macos-arm64.tgz, which Helm extracts into an asset-named directory:helm-diff-macos-arm64/diff→helm plugin list(run at the end ofinstallHelmPlugins) fails with exit code 1.Notably the
helm plugin installitself returns exit code 0 even though the conflict is reported on stderr (level=ERROR msg="failed to load plugins" ...), so the existing error handling didn't catch it.Fix
In
src/helm.ts, classify eachhelm plugin installresult and detect the duplicate-name conflict (reported on stderr regardless of exit code). When detected, remove the directory just created from the.tgzasset (reusing the existingcleanupPartialPluginInstallhelper) and treat the plugin as already installed, so the plugins directory is not left in a broken state.This also refactors the v4
.tgzinstall loop to use a singleclassifyPluginInstallhelper, keeping the verification-retry and legacy-fallback behavior intact (all existing tests still pass).Testing
npm run build,npm run lint,npm run format-checkall pass.dist/index.js.Fixes the CI failure blocking #720.