From 81c36c2c70cd2a4d0114f8897ffe933b4ce7509a Mon Sep 17 00:00:00 2001 From: Ming Hay Luk Date: Wed, 11 Dec 2024 11:49:56 -0800 Subject: [PATCH] Fix routing for invalid PR --- app/v2/pipeline/pulls/show/route.js | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/app/v2/pipeline/pulls/show/route.js b/app/v2/pipeline/pulls/show/route.js index e59434bd3..9f39f4fde 100644 --- a/app/v2/pipeline/pulls/show/route.js +++ b/app/v2/pipeline/pulls/show/route.js @@ -39,30 +39,37 @@ export default class V2PipelinePullsShowRoute extends Route { latestEvent = event; } else { const newestPrNum = newestPrNumber(prNums); - const baseUrl = `/pipelines/${pipelineId}/events?prNum=${newestPrNum}`; - const url = sha ? `${baseUrl}&sha=${sha}` : baseUrl; - latestEvent = await this.shuttle.fetchFromApi('get', url).then(events => { - return events[0]; - }); + if (newestPrNum) { + const baseUrl = `/pipelines/${pipelineId}/events?prNum=${newestPrNum}`; + const url = sha ? `${baseUrl}&sha=${sha}` : baseUrl; + + latestEvent = await this.shuttle + .fetchFromApi('get', url) + .then(events => { + return events[0]; + }); + } } let jobs = []; - if (event && !pipeline.chainPR) { - jobs = await this.shuttle.fetchFromApi( - 'get', - `/pipelines/${pipelineId}/jobs?type=pipeline` - ); + if (event) { + this.selectedPrSha.setSha(event.sha); - model.pullRequestJobs.forEach(prJob => { - if (getPrNumber(prJob) === prNum) { - jobs.push({ ...prJob, group: prNum }); - } - }); - } + if (!pipeline.chainPR) { + jobs = await this.shuttle.fetchFromApi( + 'get', + `/pipelines/${pipelineId}/jobs?type=pipeline` + ); - this.selectedPrSha.setSha(event.sha); + model.pullRequestJobs.forEach(prJob => { + if (getPrNumber(prJob) === prNum) { + jobs.push({ ...prJob, group: prNum }); + } + }); + } + } return { ...model,