From 0980680382180a2bbeecd6f9ba26e512cb5ce50b Mon Sep 17 00:00:00 2001 From: Bert Verhelst Date: Tue, 11 Aug 2026 10:44:55 +0200 Subject: [PATCH] fix(ARC-3838):: handle 404 for non existant content page https://meemoo.atlassian.net/browse/ARC-3838 --- .../content-pages/controllers/content-pages.controller.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/src/modules/content-pages/controllers/content-pages.controller.ts b/api/src/modules/content-pages/controllers/content-pages.controller.ts index 4baed921..1aac0e13 100644 --- a/api/src/modules/content-pages/controllers/content-pages.controller.ts +++ b/api/src/modules/content-pages/controllers/content-pages.controller.ts @@ -113,7 +113,7 @@ export class ContentPagesController { ): Promise { try { const user = sessionUser?.getUser(); - return await this.contentPagesService.getContentPageByLanguageAndPathForUser( + const contentPage = await this.contentPagesService.getContentPageByLanguageAndPathForUser( language || (user.language as Locale), path, user, @@ -121,9 +121,13 @@ export class ContentPagesController { ip, onlyInfo === 'true' ); + if (!contentPage) { + throw new CustomError('ContentPage not found', null, {code: 'NOT_FOUND'}, 404); + } + return contentPage; // biome-ignore lint/suspicious/noExplicitAny: error can be any type } catch (err: any) { - if (err?.response?.additionalInfo?.code === 'NOT_FOUND') { + if (err?.response?.additionalInfo?.code === 'NOT_FOUND' || err?.statusCode === 404) { throw new NotFoundException('The content page with path was not found'); } const error = new CustomError('Failed to get content page by language and path', err, {