From 7491dbd63b9c886b431fb7bd2f8730abd0a9ddae Mon Sep 17 00:00:00 2001
From: Richard LT <richard.le.terrier@gmail.com>
Date: Mon, 18 May 2020 09:14:20 +0200
Subject: [PATCH] fix(api): ignore error if wkf holder not found when loading
 pipeline (#5184)

---
 engine/api/pipeline.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/engine/api/pipeline.go b/engine/api/pipeline.go
index a1b0e1b262..126a83dfb3 100644
--- a/engine/api/pipeline.go
+++ b/engine/api/pipeline.go
@@ -335,10 +335,15 @@ func (api *API) getPipelineHandler() service.Handler {
 			wkAscodeHolder, err := workflow.LoadByRepo(ctx, api.Cache, api.mustDB(), *proj, p.FromRepository, workflow.LoadOptions{
 				WithTemplate: true,
 			})
-			if err != nil {
+			if err != nil && !sdk.ErrorIs(err, sdk.ErrNotFound) {
 				return sdk.NewErrorFrom(err, "cannot found workflow holder of the pipeline")
 			}
 			p.WorkflowAscodeHolder = wkAscodeHolder
+
+			// FIXME from_repository should never be set if the workflow holder was deleted
+			if p.WorkflowAscodeHolder == nil {
+				p.FromRepository = ""
+			}
 		}
 
 		return service.WriteJSON(w, p, http.StatusOK)