From 2d4c07512339716b2d6a799ff0a30c768b3c4d22 Mon Sep 17 00:00:00 2001 From: Takumi Sue <23391543+mikutas@users.noreply.github.com> Date: Tue, 11 Oct 2022 23:36:48 +0900 Subject: [PATCH] fix: avoid nil pointer dereference. Fixes #9269 (#9787) Signed-off-by: mikutas <23391543+mikutas@users.noreply.github.com> Signed-off-by: juchao --- workflow/controller/operator.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/workflow/controller/operator.go b/workflow/controller/operator.go index 39c41c8df3ae..73309aaf30bb 100644 --- a/workflow/controller/operator.go +++ b/workflow/controller/operator.go @@ -572,9 +572,6 @@ func (woc *wfOperationCtx) setGlobalParameters(executionParameters wfv1.Argument woc.globalParams[common.GlobalVarWorkflowParameters] = string(workflowParameters) } for _, param := range executionParameters.Parameters { - if param.Value == nil && param.ValueFrom == nil { - return fmt.Errorf("either value or valueFrom must be specified in order to set global parameter %s", param.Name) - } if param.ValueFrom != nil && param.ValueFrom.ConfigMapKeyRef != nil { cmValue, err := common.GetConfigMapValue(woc.controller.configMapInformer, woc.wf.ObjectMeta.Namespace, param.ValueFrom.ConfigMapKeyRef.Name, param.ValueFrom.ConfigMapKeyRef.Key) if err != nil { @@ -587,8 +584,10 @@ func (woc *wfOperationCtx) setGlobalParameters(executionParameters wfv1.Argument } else { woc.globalParams["workflow.parameters."+param.Name] = cmValue } - } else { + } else if param.Value != nil { woc.globalParams["workflow.parameters."+param.Name] = param.Value.String() + } else { + return fmt.Errorf("either value or valueFrom must be specified in order to set global parameter %s", param.Name) } } if woc.wf.Status.Outputs != nil {