From c74e3ddedf06467b11110b5926a3c2b64d9fd3bf Mon Sep 17 00:00:00 2001 From: Akinori Kanechika <138551445+yakanechi@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:20:41 +0900 Subject: [PATCH] update (#636) --- lib/helper.js | 5 ++++- test/lib/buildFactory.test.js | 1 + test/lib/pipeline.test.js | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/helper.js b/lib/helper.js index c3d89635..400b70ed 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -267,10 +267,13 @@ async function getManagedBuildClusterName({ annotations, pipeline, isPipelineUpd const buildCluster = findBuildCluster(allBuildClusters, buildClusterName, pipeline.scmContext); if (!buildCluster) { - throw new Error( + const error = new Error( `Cluster specified in screwdriver.cd/buildCluster ${buildClusterName} ` + `for scmContext ${pipeline.scmContext} and group ${groupName} does not exist.` ); + + error.statusCode = 400; + throw error; } if (buildCluster.scmContext !== pipeline.scmContext || !hasClusterAccess(pipeline.name, buildCluster)) { diff --git a/test/lib/buildFactory.test.js b/test/lib/buildFactory.test.js index ee58b6ff..b1c72fdd 100644 --- a/test/lib/buildFactory.test.js +++ b/test/lib/buildFactory.test.js @@ -689,6 +689,7 @@ describe('Build Factory', () => { 'Cluster specified in screwdriver.cd/buildCluster iOS ' + `for scmContext ${scmContext} and group default does not exist.` ); + assert.strictEqual(err.statusCode, 400); }); }); diff --git a/test/lib/pipeline.test.js b/test/lib/pipeline.test.js index 78254647..87fe1767 100644 --- a/test/lib/pipeline.test.js +++ b/test/lib/pipeline.test.js @@ -3213,6 +3213,7 @@ describe('Pipeline Model', () => { 'Cluster specified in screwdriver.cd/buildCluster iOS ' + `for scmContext ${pipeline.scmContext} and group default does not exist.` ); + assert.strictEqual(err.statusCode, 400); }); });