From 0c21c5b5cc3545ec93981ff25684146a64410c68 Mon Sep 17 00:00:00 2001 From: "Pete." Date: Tue, 23 Jun 2026 11:24:01 +0100 Subject: [PATCH] Fix panic running plugin subcommands with nil context stripe projects (init, status, catalog, ...) panics with "cannot create context from nil parent": runPluginCmd passes cmd.Context() into withSIGTERMCancel, but the context is nil for plugin subcommand stubs, so context.WithCancel(nil) panics. Default the parent context to context.Background() when nil, mirroring the guard already used on the plugin help path. Fixes #1707 --- pkg/cmd/plugin_cmds.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/cmd/plugin_cmds.go b/pkg/cmd/plugin_cmds.go index e252265f3..f1aca4b77 100644 --- a/pkg/cmd/plugin_cmds.go +++ b/pkg/cmd/plugin_cmds.go @@ -102,7 +102,15 @@ func addPluginSubcommandStubs(parent *cobra.Command, commands []plugins.CommandI // runPluginCmd hands off to the plugin itself to take over func (ptc *pluginTemplateCmd) runPluginCmd(cmd *cobra.Command, args []string) error { - ctx := withSIGTERMCancel(cmd.Context(), func() { + // Plugin subcommand stubs can reach this path with a nil command context, + // which makes withSIGTERMCancel -> context.WithCancel panic ("cannot create + // context from nil parent"). Fall back to a background context, mirroring the + // guard already used on the help path above. + parentCtx := cmd.Context() + if parentCtx == nil { + parentCtx = context.Background() + } + ctx := withSIGTERMCancel(parentCtx, func() { log.WithFields(log.Fields{ "prefix": "cmd.pluginCmd.runPluginCmd", }).Debug("Ctrl+C received, cleaning up...")