Skip to content

fix: resolve duplicate helm plugin conflict when auto-init is enabled - #726

Merged
yxxhero merged 4 commits into
mainfrom
fix/duplicate-plugin-conflict-auto-init
Jun 23, 2026
Merged

yxxhero merged 4 commits into
mainfrom
fix/duplicate-plugin-conflict-auto-init

Conversation

@yxxhero

@yxxhero yxxhero commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problem

The test-action-auto-init job in basic-validation.yml is failing on macOS and Windows (see PR #720 CI):

Error: two plugins claim the name "diff" at
  "/Users/runner/Library/helm/plugins/helm-diff" and
  "/Users/runner/Library/helm/plugins/helm-diff-macos-arm64"

Root cause

When helmfile-auto-init: true is combined with helm-plugins:

  1. helmfile init --force installs the diff plugin into a repo-named directory: helm-diff/
  2. The action's Helm v4 .tgz install path resolves and installs the platform asset helm-diff-macos-arm64.tgz, which Helm extracts into an asset-named directory: helm-diff-macos-arm64/
  3. Both directories declare plugin name diff → helm plugin list (run at the end of installHelmPlugins) fails with exit code 1.

Notably the helm plugin install itself 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 each helm plugin install result and detect the duplicate-name conflict (reported on stderr regardless of exit code). When detected, remove the directory just created from the .tgz asset (reusing the existing cleanupPartialPluginInstall helper) and treat the plugin as already installed, so the plugins directory is not left in a broken state.

This also refactors the v4 .tgz install loop to use a single classifyPluginInstall helper, keeping the verification-retry and legacy-fallback behavior intact (all existing tests still pass).

Testing

  • Added a test reproducing the duplicate conflict (exit 0 + stderr conflict) and asserting the duplicate directory is removed.
  • npm run build, npm run lint, npm run format-check all pass.
  • Full suite: 37/37 tests passing.
  • Rebuilt dist/index.js.

Fixes the CI failure blocking #720.

yxxhero added 4 commits June 23, 2026 17:56
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.
@yxxhero
yxxhero merged commit ece8295 into main Jun 23, 2026
12 checks passed
@yxxhero
yxxhero deleted the fix/duplicate-plugin-conflict-auto-init branch June 23, 2026 13:12
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.

1 participant