From b088d672261cb1ac0e7c51d5e43a4a6b643deff9 Mon Sep 17 00:00:00 2001 From: Patrick Zhao Date: Tue, 21 Jan 2025 14:18:53 +0800 Subject: [PATCH] fix agent panic in RunStep Signed-off-by: Patrick Zhao --- pkg/cli/zadig-agent/internal/agent/step/step.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cli/zadig-agent/internal/agent/step/step.go b/pkg/cli/zadig-agent/internal/agent/step/step.go index d24c0fc44e..d983e6b4ad 100644 --- a/pkg/cli/zadig-agent/internal/agent/step/step.go +++ b/pkg/cli/zadig-agent/internal/agent/step/step.go @@ -18,6 +18,7 @@ package step import ( "context" + "errors" "fmt" "github.com/koderover/zadig/v2/pkg/cli/zadig-agent/helper/log" @@ -48,6 +49,11 @@ func RunStep(ctx context.Context, jobCtx *jobctl.JobContext, step *commonmodels. var stepInstance Step var err error + if step == nil { + log.Errorf("step is nil") + return errors.New("step is nil") + } + switch step.StepType { case "batch_file": stepInstance, err = script.NewBatchFileStep(jobCtx.Outputs, step.Spec, dirs, envs, secretEnvs, logger)