From d974b015d030c608158ff0c3fa3b7f4cbb8eadd3 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Fri, 4 Oct 2024 13:06:15 +0300 Subject: [PATCH] fix: Incorrect error message on calling wrong webhook method (#11093) --- .../errors/response-errors/webhook-not-found.error.ts | 11 +++++++---- packages/cli/src/webhooks/live-webhooks.ts | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/errors/response-errors/webhook-not-found.error.ts b/packages/cli/src/errors/response-errors/webhook-not-found.error.ts index 648a7a0106..8b2d8bd26c 100644 --- a/packages/cli/src/errors/response-errors/webhook-not-found.error.ts +++ b/packages/cli/src/errors/response-errors/webhook-not-found.error.ts @@ -47,10 +47,13 @@ export class WebhookNotFoundError extends NotFoundError { ) { const errorMsg = webhookNotFoundErrorMessage({ path, httpMethod, webhookMethods }); - const hintMsg = - hint === 'default' - ? "Click the 'Test workflow' button on the canvas, then try again. (In test mode, the webhook only works for one call after you click this button)" - : "The workflow must be active for a production URL to run successfully. You can activate the workflow using the toggle in the top-right of the editor. Note that unlike test URL calls, production URL calls aren't shown on the canvas (only in the executions list)"; + let hintMsg = ''; + if (!webhookMethods?.length) { + hintMsg = + hint === 'default' + ? "Click the 'Test workflow' button on the canvas, then try again. (In test mode, the webhook only works for one call after you click this button)" + : "The workflow must be active for a production URL to run successfully. You can activate the workflow using the toggle in the top-right of the editor. Note that unlike test URL calls, production URL calls aren't shown on the canvas (only in the executions list)"; + } super(errorMsg, hintMsg); } diff --git a/packages/cli/src/webhooks/live-webhooks.ts b/packages/cli/src/webhooks/live-webhooks.ts index d567fe11b2..458701caee 100644 --- a/packages/cli/src/webhooks/live-webhooks.ts +++ b/packages/cli/src/webhooks/live-webhooks.ts @@ -160,8 +160,9 @@ export class LiveWebhooks implements IWebhookManager { } const webhook = await this.webhookService.findWebhook(httpMethod, path); + const webhookMethods = await this.getWebhookMethods(path); if (webhook === null) { - throw new WebhookNotFoundError({ path, httpMethod }, { hint: 'production' }); + throw new WebhookNotFoundError({ path, httpMethod, webhookMethods }, { hint: 'production' }); } return webhook;