fix: Incorrect error message on calling wrong webhook method (#11093)

This commit is contained in:
Michael Kret 2024-10-04 13:06:15 +03:00 committed by GitHub
parent b925791c15
commit d974b015d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View file

@ -47,10 +47,13 @@ export class WebhookNotFoundError extends NotFoundError {
) { ) {
const errorMsg = webhookNotFoundErrorMessage({ path, httpMethod, webhookMethods }); const errorMsg = webhookNotFoundErrorMessage({ path, httpMethod, webhookMethods });
const hintMsg = let hintMsg = '';
hint === 'default' if (!webhookMethods?.length) {
? "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)" hintMsg =
: "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)"; 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); super(errorMsg, hintMsg);
} }

View file

@ -160,8 +160,9 @@ export class LiveWebhooks implements IWebhookManager {
} }
const webhook = await this.webhookService.findWebhook(httpMethod, path); const webhook = await this.webhookService.findWebhook(httpMethod, path);
const webhookMethods = await this.getWebhookMethods(path);
if (webhook === null) { if (webhook === null) {
throw new WebhookNotFoundError({ path, httpMethod }, { hint: 'production' }); throw new WebhookNotFoundError({ path, httpMethod, webhookMethods }, { hint: 'production' });
} }
return webhook; return webhook;