From 580b03f2b987db254b7b4ac0efbebf2be721b156 Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Fri, 14 Mar 2025 15:49:04 +0200 Subject: [PATCH] chore: handle conferencing callback missing state error (#20081) --- .../controllers/conferencing.controller.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts b/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts index aa84ae4fb9..fead0f07e3 100644 --- a/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts +++ b/apps/api/v2/src/modules/conferencing/controllers/conferencing.controller.ts @@ -35,6 +35,7 @@ import { Redirect, UnauthorizedException, Req, + HttpException, } from "@nestjs/common"; import { ApiOperation, ApiTags as DocsTags } from "@nestjs/swagger"; import { plainToInstance } from "class-transformer"; @@ -56,7 +57,7 @@ export type OAuthCallbackState = { }) @DocsTags("Conferencing") export class ConferencingController { - private readonly logger = new Logger("Platform Gcal Provider"); + private readonly logger = new Logger("ConferencingController"); constructor( private readonly tokensRepository: TokensRepository, @@ -144,6 +145,10 @@ export class ConferencingController { @Query("error") error: string | undefined, @Query("error_description") error_description: string | undefined ): Promise<{ url: string }> { + if (!state) { + throw new BadRequestException("Missing `state` query param"); + } + const decodedCallbackState: OAuthCallbackState = JSON.parse(state); try { const userId = await this.tokensRepository.getAccessTokenOwnerId(decodedCallbackState.accessToken); @@ -169,6 +174,9 @@ export class ConferencingController { ); } } catch (error) { + if (error instanceof HttpException || error instanceof Error) { + this.logger.error(error.message); + } return { url: decodedCallbackState.onErrorReturnTo ?? "", };