Skip to content

Commit 1969e6b

Browse files
committed
Refactor workflow dispatch
Signed-off-by: Bence Santha <[email protected]>
1 parent 0357003 commit 1969e6b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

services/actions/workflow.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,19 @@ func DispatchActionWorkflow(ctx *context.APIContext, workflowID string, opt *api
194194
return
195195
}
196196
workflows, err := jobparser.Parse(content)
197-
if err != nil || len(workflows) == 0 {
197+
if err != nil {
198198
ctx.Error(http.StatusInternalServerError, "WorkflowParseError", err.Error())
199199
return
200200
}
201+
if len(workflows) == 0 {
202+
ctx.Error(http.StatusNotFound, "WorkflowNotFound", fmt.Sprintf("workflow '%s' is not found", workflowID))
203+
return
204+
}
201205
workflow = workflows[0]
202206
break
203207
}
204208
}
205209

206-
if workflow == nil {
207-
ctx.Error(http.StatusNotFound, "WorkflowNotFound", fmt.Sprintf("workflow '%s' is not found", workflowID))
208-
return
209-
}
210-
211210
// Process workflow inputs
212211
inputs := processWorkflowInputs(opt, &model.Workflow{
213212
RawOn: workflow.RawOn,

0 commit comments

Comments
 (0)