From bcde86ddd77dbe489b11c4598eb94f8630640aee Mon Sep 17 00:00:00 2001 From: calebak404 <78181572+calebak404@users.noreply.github.com> Date: Tue, 31 Oct 2023 11:05:26 -0500 Subject: [PATCH] add length check to avoid panic add length check to match linux_web_app to avoid potential panic in windows_web_app linux change done in #21328 --- internal/services/appservice/helpers/auto_heal.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/services/appservice/helpers/auto_heal.go b/internal/services/appservice/helpers/auto_heal.go index 06a00c5fa62ef..62e34c832af47 100644 --- a/internal/services/appservice/helpers/auto_heal.go +++ b/internal/services/appservice/helpers/auto_heal.go @@ -401,7 +401,17 @@ func expandAutoHealSettingsWindows(autoHealSettings []AutoHealSettingWindows) *w } autoHeal := autoHealSettings[0] + + if len(autoHeal.actions) > 0 { + action := autoHeal.Actions[0] + result.Actions.ActionType = web.AutoHealActionType(action.ActionType) + result.Actions.MinProcessExecutionTime = pointer.To(action.MinimumProcessTime) + } + if len(autoHeal.Triggers) == 0 { + return result + } + triggers := autoHeal.Triggers[0] if len(triggers.Requests) == 1 { result.Triggers.Requests = &web.RequestsBasedTrigger{ @@ -462,10 +472,7 @@ func expandAutoHealSettingsWindows(autoHealSettings []AutoHealSettingWindows) *w result.Triggers.StatusCodes = &statusCodeTriggers result.Triggers.StatusCodesRange = &statusCodeRangeTriggers } - - action := autoHeal.Actions[0] - result.Actions.ActionType = web.AutoHealActionType(action.ActionType) - result.Actions.MinProcessExecutionTime = pointer.To(action.MinimumProcessTime) + if len(action.CustomAction) != 0 { customAction := action.CustomAction[0] result.Actions.CustomAction = &web.AutoHealCustomAction{