diff --git a/pkg/action/action.go b/pkg/action/action.go index bcc91816c..4f4c26e61 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -280,6 +280,10 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, var hs []*release.Hook b := bytes.NewBuffer(nil) + if ch == nil { + return hs, b, "", errors.New("chart is nil") + } + caps, err := cfg.getCapabilities() if err != nil { return hs, b, "", err diff --git a/pkg/action/install.go b/pkg/action/install.go index d73eca619..a5fcc00b4 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -291,6 +291,9 @@ func (i *Install) RunWithContext(ctx context.Context, ch ci.Charter, vals map[st default: return nil, errors.New("invalid chart apiVersion") } + if chrt == nil { + return nil, errors.New("chart is nil") + } if interactWithServer(i.DryRunStrategy) { if err := i.cfg.KubeClient.IsReachable(); err != nil { diff --git a/pkg/action/install_test.go b/pkg/action/install_test.go index 4dbeb7c79..a148b828c 100644 --- a/pkg/action/install_test.go +++ b/pkg/action/install_test.go @@ -1245,3 +1245,16 @@ func TestInstallRelease_WaitOptionsPassedDownstream(t *testing.T) { // Verify that WaitOptions were passed to GetWaiter is.NotEmpty(failer.RecordedWaitOptions, "WaitOptions should be passed to GetWaiter") } + +func TestInstallRun_NilChart(t *testing.T) { + is := assert.New(t) + + instAction := installAction(t) + instAction.DryRunStrategy = DryRunClient + + vals := map[string]any{} + // Pass a typed nil *chart.Chart as the ci.Charter interface + _, err := instAction.Run((*chart.Chart)(nil), vals) + is.Error(err) + is.Contains(err.Error(), "chart is nil") +}