From e8faf2911624d197af7861ec3a8c55c661d39189 Mon Sep 17 00:00:00 2001 From: Sokratis Vidros Date: Tue, 5 Nov 2024 23:30:48 +0200 Subject: [PATCH] fix(api): Remove double logging of Bridge errors We log once in ExecuteBridgeRequest so there is no need to log the error again in get-bridge-status.usecase.ts --- apps/api/src/app/bridge/bridge.controller.ts | 4 +-- .../get-bridge-status.usecase.ts | 29 ++++++------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/apps/api/src/app/bridge/bridge.controller.ts b/apps/api/src/app/bridge/bridge.controller.ts index 61fa91fba4b..134e18baff2 100644 --- a/apps/api/src/app/bridge/bridge.controller.ts +++ b/apps/api/src/app/bridge/bridge.controller.ts @@ -50,13 +50,11 @@ export class BridgeController { @Get('/status') @UseGuards(UserAuthGuard) async health(@UserSession() user: UserSessionData) { - const result = await this.getBridgeStatus.execute( + return this.getBridgeStatus.execute( GetBridgeStatusCommand.create({ environmentId: user.environmentId, }) ); - - return result; } @Post('/preview/:workflowId/:stepId') diff --git a/apps/api/src/app/bridge/usecases/get-bridge-status/get-bridge-status.usecase.ts b/apps/api/src/app/bridge/usecases/get-bridge-status/get-bridge-status.usecase.ts index 62e44f52300..7d92b2181bb 100644 --- a/apps/api/src/app/bridge/usecases/get-bridge-status/get-bridge-status.usecase.ts +++ b/apps/api/src/app/bridge/usecases/get-bridge-status/get-bridge-status.usecase.ts @@ -11,25 +11,14 @@ export class GetBridgeStatus { constructor(private executeBridgeRequest: ExecuteBridgeRequest) {} async execute(command: GetBridgeStatusCommand): Promise { - try { - const response = (await this.executeBridgeRequest.execute( - ExecuteBridgeRequestCommand.create({ - environmentId: command.environmentId, - action: GetActionEnum.HEALTH_CHECK, - workflowOrigin: WorkflowOriginEnum.EXTERNAL, - statelessBridgeUrl: command.statelessBridgeUrl, - retriesLimit: 1, - }) - )) as ExecuteBridgeRequestDto; - - return response; - } catch (err: any) { - Logger.error( - `Failed to verify Bridge endpoint for environment ${command.environmentId} with error: ${(err as Error).message || err}`, - (err as Error).stack, - LOG_CONTEXT - ); - throw err; - } + return (await this.executeBridgeRequest.execute( + ExecuteBridgeRequestCommand.create({ + environmentId: command.environmentId, + action: GetActionEnum.HEALTH_CHECK, + workflowOrigin: WorkflowOriginEnum.EXTERNAL, + statelessBridgeUrl: command.statelessBridgeUrl, + retriesLimit: 1, + }) + )) as ExecuteBridgeRequestDto; } }