From 837d0e9c75c06bc11e88f50e0f305e753ec1b4ed Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Oct 2026 17:31:08 +0100 Subject: [PATCH] Bugfix/not found status in benchmarks endpoints (#8331) * Fix not found status * Update changelog --- CHANGELOG.md | 1 + .../benchmarks/benchmarks.controller.ts | 46 ++++++++++--------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 831a699785..3dbe3b7316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed the double submission of forms in the account detail dialog, the create or update access dialog, the historical market data editor, the import activities dialog, the coupon system and the create asset profile dialog of the admin control panel - Fixed an issue where users could grant a private access to themselves +- Fixed the status code of the endpoints to add and delete a benchmark if the asset profile does not exist ## 3.93.0 - 2026-10-25 diff --git a/apps/api/src/app/endpoints/benchmarks/benchmarks.controller.ts b/apps/api/src/app/endpoints/benchmarks/benchmarks.controller.ts index 0930eb5b17..94c204453e 100644 --- a/apps/api/src/app/endpoints/benchmarks/benchmarks.controller.ts +++ b/apps/api/src/app/endpoints/benchmarks/benchmarks.controller.ts @@ -30,7 +30,7 @@ import { UseInterceptors } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; -import { DataSource } from '@prisma/client'; +import { DataSource, SymbolProfile } from '@prisma/client'; import { StatusCodes, getReasonPhrase } from 'http-status-codes'; import { BenchmarksService } from './benchmarks.service'; @@ -51,26 +51,28 @@ export class BenchmarksController { public async addBenchmark( @Body() { dataSource, symbol }: AssetProfileIdentifier ) { + let benchmark: Partial | null; + try { - const benchmark = await this.benchmarkService.addBenchmark({ + benchmark = await this.benchmarkService.addBenchmark({ dataSource, symbol }); - - if (!benchmark) { - throw new HttpException( - getReasonPhrase(StatusCodes.NOT_FOUND), - StatusCodes.NOT_FOUND - ); - } - - return benchmark; } catch { throw new HttpException( getReasonPhrase(StatusCodes.INTERNAL_SERVER_ERROR), StatusCodes.INTERNAL_SERVER_ERROR ); } + + if (!benchmark) { + throw new HttpException( + getReasonPhrase(StatusCodes.NOT_FOUND), + StatusCodes.NOT_FOUND + ); + } + + return benchmark; } @Delete(':dataSource/:symbol') @@ -80,26 +82,28 @@ export class BenchmarksController { @Param('dataSource') dataSource: DataSource, @Param('symbol') symbol: string ) { + let benchmark: Partial | null; + try { - const benchmark = await this.benchmarkService.deleteBenchmark({ + benchmark = await this.benchmarkService.deleteBenchmark({ dataSource, symbol }); - - if (!benchmark) { - throw new HttpException( - getReasonPhrase(StatusCodes.NOT_FOUND), - StatusCodes.NOT_FOUND - ); - } - - return benchmark; } catch { throw new HttpException( getReasonPhrase(StatusCodes.INTERNAL_SERVER_ERROR), StatusCodes.INTERNAL_SERVER_ERROR ); } + + if (!benchmark) { + throw new HttpException( + getReasonPhrase(StatusCodes.NOT_FOUND), + StatusCodes.NOT_FOUND + ); + } + + return benchmark; } @Get()