Skip to content

fix(plugin/install): thread cmd through confirmPluginDepsInstall - #810

Open
ajalon1 wants to merge 1 commit into
aj/non-interactive-telemetryfrom
aj/fix-plugin-install-yes-flag
Open

fix(plugin/install): thread cmd through confirmPluginDepsInstall#810
ajalon1 wants to merge 1 commit into
aj/non-interactive-telemetryfrom
aj/fix-plugin-install-yes-flag

Conversation

@ajalon1

@ajalon1 ajalon1 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

RATIONALE

Part of the RootFactory stack (#802, #803). confirmPluginDepsInstall was closing over a package-level yesFlag variable and passing nil to cli.IsNonInteractive, bypassing the proper flag-read path.

When cmd == nil, IsNonInteractive falls back to the weaker viperx.GetBool(YesFlagName) path instead of reading the flag directly from the command. The package-level yesFlag is also shared state that leaks across successive Execute() calls in tests or any harness that re-uses the same process.

CHANGES

  • Remove the package-level var yesFlag bool; re-register the flag via cmd.Flags().BoolP (no package-level binding)
  • Thread *cobra.Command through: runInstallrunInstallFromRegistry / runInstallFromFile / runInstallFromURLcheckAndInstallPluginDepsconfirmPluginDepsInstall
  • Replace yesFlag || cli.IsNonInteractive(nil) with cli.IsNonInteractive(cmd), which checks --yes via cmd.Flags(), the NON_INTERACTIVE env var, and viperx in priority order
  • Update tests: add makeCmd(t, yes bool) helper, remove all origYesFlag/defer cleanup patterns

Note

Low Risk
Small CLI plumbing refactor for non-interactive confirmation; no auth, install, or dependency-install logic changes beyond how --yes is read.

Overview
Stops plugin-install dep confirmation from using a package-level yesFlag and cli.IsNonInteractive(nil), which skipped the real --yes flag path and leaked state across Execute() calls.

--yes is now registered without a package binding. runInstall threads *cobra.Command through the file/URL/registry install paths into confirmPluginDepsInstall, which uses cli.IsNonInteractive(cmd) so --yes, env, and viper are resolved in the intended order. Tests use a makeCmd helper instead of mutating global flag state.

Reviewed by Cursor Bugbot for commit e3e5760. Configure here.

Replace the package-level yesFlag variable with proper cmd threading.
confirmPluginDepsInstall now receives the real *cobra.Command and calls
cli.IsNonInteractive(cmd) directly, which checks --yes via cmd.Flags(),
the NON_INTERACTIVE env var, and viperx in priority order.

Previously, passing nil to IsNonInteractive fell back to the weaker
viperx-only path and the package-level yesFlag was shared state that
could leak across successive Execute calls in the same process.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@ajalon1
ajalon1 force-pushed the aj/fix-plugin-install-yes-flag branch from 25590f9 to beb8a68 Compare August 21, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant