diff --git a/changelogs/unreleased/5675-dymurray b/changelogs/unreleased/5675-dymurray new file mode 100644 index 000000000..a7162e48a --- /dev/null +++ b/changelogs/unreleased/5675-dymurray @@ -0,0 +1 @@ +Prevent nil panic on exec restore hooks diff --git a/pkg/controller/restore_controller.go b/pkg/controller/restore_controller.go index 038e97109..9e2eb31d7 100644 --- a/pkg/controller/restore_controller.go +++ b/pkg/controller/restore_controller.go @@ -342,10 +342,12 @@ func (c *restoreController) validateAndComplete(restore *api.Restore, pluginMana } for _, resource := range restoreHooks { for _, h := range resource.RestoreHooks { - for _, container := range h.Init.InitContainers { - err = hook.ValidateContainer(container.Raw) - if err != nil { - restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, err.Error()) + if h.Init != nil { + for _, container := range h.Init.InitContainers { + err = hook.ValidateContainer(container.Raw) + if err != nil { + restore.Status.ValidationErrors = append(restore.Status.ValidationErrors, err.Error()) + } } } }