From 8d041a05952b11cd94354586be0fa9b5badf84ae Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Mon, 13 Jun 2022 14:57:24 +0200 Subject: [PATCH] fix(ui): nil pointer (#6210) Signed-off-by: Yvonnick Esnault --- ui/src/app/model/pipeline.model.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/src/app/model/pipeline.model.ts b/ui/src/app/model/pipeline.model.ts index dbb6ebb141..f4924fc0bb 100644 --- a/ui/src/app/model/pipeline.model.ts +++ b/ui/src/app/model/pipeline.model.ts @@ -163,9 +163,17 @@ export class Pipeline { s.jobs.forEach(j => { let nextJobRef; let loopAgain = true; + let idxJob; do { nextJobRef = Math.random(); - loopAgain = editPipeline.stages.findIndex(st => st.jobs.findIndex(jb => jb.ref === nextRef) !== -1) !== -1; + idxJob = editPipeline.stages.findIndex(st => { + if (st && st.jobs) { + return st.jobs.findIndex(jb => jb.ref === nextRef); + } else { + return -1; + } + }); + loopAgain = idxJob !== -1; } while (loopAgain); j.ref = nextJobRef; });