From 65f4f88fdfb6519e3bdc43faae690d3b7a29f776 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Thu, 16 Mar 2023 12:02:23 +0200 Subject: [PATCH] fix: bug fix - `end` the response when projectScopedStickiness is disabled (#3332) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes a bug where the api call to getProjectSettings was left hanging because no `end` was specified on the server ## About the changes Closes # ### Important files ## Discussion points --------- Signed-off-by: andreas-unleash Co-authored-by: Nuno Góis --- src/lib/routes/admin-api/project/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/routes/admin-api/project/index.ts b/src/lib/routes/admin-api/project/index.ts index b31e347666a..53abc494b6b 100644 --- a/src/lib/routes/admin-api/project/index.ts +++ b/src/lib/routes/admin-api/project/index.ts @@ -28,6 +28,7 @@ import { OpenApiService, SettingService } from '../../../services'; import { IAuthRequest } from '../../unleash-types'; import { ProjectApiTokenController } from './api-token'; import ProjectArchiveController from './project-archive'; +import NotFoundError from '../../../error/notfound-error'; const STICKINESS_KEY = 'stickiness'; const DEFAULT_STICKINESS = 'default'; @@ -164,8 +165,7 @@ export default class ProjectApi extends Controller { res: Response, ): Promise { if (!this.config.flagResolver.isEnabled('projectScopedStickiness')) { - res.status(404); - return Promise.resolve(); + throw new NotFoundError('Project scoped stickiness is not enabled'); } const { projectId } = req.params; const stickinessSettings = await this.settingService.get( @@ -192,8 +192,7 @@ export default class ProjectApi extends Controller { res: Response, ): Promise { if (!this.config.flagResolver.isEnabled('projectScopedStickiness')) { - res.status(404); - return Promise.resolve(); + throw new NotFoundError('Project scoped stickiness is not enabled'); } const { projectId } = req.params; const { defaultStickiness } = req.body;