From 1969e6b4adf7d9680fd4dc99850bcab061603ff8 Mon Sep 17 00:00:00 2001 From: Bence Santha Date: Sat, 12 Oct 2024 10:15:12 +0200 Subject: [PATCH] Refactor workflow dispatch Signed-off-by: Bence Santha --- services/actions/workflow.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/services/actions/workflow.go b/services/actions/workflow.go index f136eb5f7d..f02bb207d2 100644 --- a/services/actions/workflow.go +++ b/services/actions/workflow.go @@ -194,20 +194,19 @@ func DispatchActionWorkflow(ctx *context.APIContext, workflowID string, opt *api return } workflows, err := jobparser.Parse(content) - if err != nil || len(workflows) == 0 { + if err != nil { ctx.Error(http.StatusInternalServerError, "WorkflowParseError", err.Error()) return } + if len(workflows) == 0 { + ctx.Error(http.StatusNotFound, "WorkflowNotFound", fmt.Sprintf("workflow '%s' is not found", workflowID)) + return + } workflow = workflows[0] break } } - if workflow == nil { - ctx.Error(http.StatusNotFound, "WorkflowNotFound", fmt.Sprintf("workflow '%s' is not found", workflowID)) - return - } - // Process workflow inputs inputs := processWorkflowInputs(opt, &model.Workflow{ RawOn: workflow.RawOn,