From c855935f847f1396ffa9319e807b409057f9dc65 Mon Sep 17 00:00:00 2001 From: Guiheux Steven Date: Mon, 15 Jun 2020 16:47:23 +0200 Subject: [PATCH] fix(api): load application no-ascode (#5255) --- engine/api/application.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/engine/api/application.go b/engine/api/application.go index ae811e49c4..359cb582a0 100644 --- a/engine/api/application.go +++ b/engine/api/application.go @@ -150,17 +150,19 @@ func (api *API) getApplicationHandler() service.Handler { app.Usage = &usage } - proj, err := project.Load(api.mustDB(), projectKey) - if err != nil { - return err - } - wkAscodeHolder, err := workflow.LoadByRepo(ctx, api.mustDB(), *proj, app.FromRepository, workflow.LoadOptions{ - WithTemplate: true, - }) - if err != nil && !sdk.ErrorIs(err, sdk.ErrNotFound) { - return sdk.NewErrorFrom(err, "cannot found workflow holder of the pipeline") + if app.FromRepository != "" { + proj, err := project.Load(api.mustDB(), projectKey) + if err != nil { + return err + } + wkAscodeHolder, err := workflow.LoadByRepo(ctx, api.mustDB(), *proj, app.FromRepository, workflow.LoadOptions{ + WithTemplate: true, + }) + if err != nil && !sdk.ErrorIs(err, sdk.ErrNotFound) { + return sdk.NewErrorFrom(err, "cannot found workflow holder of the pipeline") + } + app.WorkflowAscodeHolder = wkAscodeHolder } - app.WorkflowAscodeHolder = wkAscodeHolder return service.WriteJSON(w, app, http.StatusOK) }