From 0bc7a6720d3790030c126d43febd1e66cb988cd2 Mon Sep 17 00:00:00 2001 From: Richard LT Date: Fri, 21 Oct 2022 09:11:03 +0200 Subject: [PATCH] fix(api): compute workflow v3 preview (#6346) --- engine/api/workflow.go | 3 +++ engine/api/workflow/dao.go | 4 ++++ engine/api/workflow_run.go | 3 +++ 3 files changed, 10 insertions(+) diff --git a/engine/api/workflow.go b/engine/api/workflow.go index c6247b0e46..55d15a45c6 100644 --- a/engine/api/workflow.go +++ b/engine/api/workflow.go @@ -219,6 +219,9 @@ func (api *API) getWorkflowHandler() service.Handler { vars := mux.Vars(r) key := vars["key"] name := vars["permWorkflowNameAdvanced"] + if name == "" { + name = vars["permWorkflowName"] // Useful for workflowv3 routes + } withUsage := service.FormBool(r, "withUsage") withAudits := service.FormBool(r, "withAudits") withLabels := service.FormBool(r, "withLabels") diff --git a/engine/api/workflow/dao.go b/engine/api/workflow/dao.go index 11a31b4f1f..c55f19489e 100644 --- a/engine/api/workflow/dao.go +++ b/engine/api/workflow/dao.go @@ -257,6 +257,10 @@ func Load(ctx context.Context, db gorp.SqlExecutor, _ cache.Store, proj sdk.Proj ctx, end := telemetry.Span(ctx, "workflow.Load") defer end() + if name == "" { + return nil, sdk.NewErrorFrom(sdk.ErrInvalidData, "invalid given workflow name") + } + dao := opts.GetWorkflowDAO() dao.Filters.ProjectKey = proj.Key dao.Filters.WorkflowName = name diff --git a/engine/api/workflow_run.go b/engine/api/workflow_run.go index 76f788092d..be98fa6d49 100644 --- a/engine/api/workflow_run.go +++ b/engine/api/workflow_run.go @@ -266,6 +266,9 @@ func (api *API) getWorkflowRunHandler() service.Handler { vars := mux.Vars(r) key := vars["key"] name := vars["permWorkflowNameAdvanced"] + if name == "" { + name = vars["permWorkflowName"] // Useful for workflowv3 routes + } number, err := requestVarInt(r, "number") if err != nil { return err