From 5ddc25749248e1daf79ca2bc695374eac6f3020d Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Fri, 9 May 2025 15:58:16 +0100 Subject: [PATCH 1/2] fix: add warn message to not found resource --- api/src/channel/lib/Handler.ts | 5 +++++ api/src/channel/webhook.controller.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/api/src/channel/lib/Handler.ts b/api/src/channel/lib/Handler.ts index c454b365..7e87676d 100644 --- a/api/src/channel/lib/Handler.ts +++ b/api/src/channel/lib/Handler.ts @@ -311,6 +311,7 @@ export default abstract class ChannelHandler< const [name, _suffix] = this.getName().split('-'); if ('id' in attachment) { if (!attachment || !attachment.id) { + this.logger.warn('Unable to build public URL: Empty attachment ID'); return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`); } @@ -330,6 +331,10 @@ export default abstract class ChannelHandler< // In case the url is external return attachment.url; } else { + this.logger.warn( + 'Unable to resolve the attachment public URL.', + attachment, + ); return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`); } } diff --git a/api/src/channel/webhook.controller.ts b/api/src/channel/webhook.controller.ts index e8e4f0eb..63a14962 100644 --- a/api/src/channel/webhook.controller.ts +++ b/api/src/channel/webhook.controller.ts @@ -1,5 +1,5 @@ /* - * Copyright © 2024 Hexastack. All rights reserved. + * Copyright © 2025 Hexastack. All rights reserved. * * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. @@ -92,6 +92,6 @@ export class WebhookController { @Roles('public') @Get(':channel/not-found') async handleNotFound(@Res() res: Response) { - return res.status(404).send({ error: 'Not found!' }); + return res.status(404).send({ error: 'Resource not found!' }); } } From 72c9484ff6c451cca24ac88c1ef55d3c95354e5c Mon Sep 17 00:00:00 2001 From: Mohamed Marrouchi Date: Mon, 12 May 2025 14:33:08 +0100 Subject: [PATCH 2/2] fix: extra check --- api/src/channel/lib/Handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/channel/lib/Handler.ts b/api/src/channel/lib/Handler.ts index 7e87676d..3d76f47e 100644 --- a/api/src/channel/lib/Handler.ts +++ b/api/src/channel/lib/Handler.ts @@ -309,7 +309,7 @@ export default abstract class ChannelHandler< */ public async getPublicUrl(attachment: AttachmentRef | Attachment) { const [name, _suffix] = this.getName().split('-'); - if ('id' in attachment) { + if (attachment && 'id' in attachment) { if (!attachment || !attachment.id) { this.logger.warn('Unable to build public URL: Empty attachment ID'); return buildURL(config.apiBaseUrl, `/webhook/${name}/not-found`);