fix(core): Better error message in Webhook node when using the POST method

This commit is contained in:
Michael Kret
2023-05-02 17:27:05 +03:00
committed by GitHub
parent 5364a2dff3
commit a0dd17e115
4 changed files with 72 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ import type { IResponseCallbackData, IWorkflowDb } from '@/Interfaces';
import { Push } from '@/push';
import * as ResponseHelper from '@/ResponseHelper';
import * as WebhookHelpers from '@/WebhookHelpers';
import { webhookNotFoundErrorMessage } from './utils';
const WEBHOOK_TEST_UNREGISTERED_HINT =
"Click the 'Execute workflow' button on the canvas, then try again. (In test mode, the webhook only works for one call after you click this button)";
@@ -69,8 +70,9 @@ export class TestWebhooks {
webhookData = activeWebhooks.get(httpMethod, pathElements.join('/'), webhookId);
if (webhookData === undefined) {
// The requested webhook is not registered
const methods = await this.getWebhookMethods(path);
throw new ResponseHelper.NotFoundError(
`The requested webhook "${httpMethod} ${path}" is not registered.`,
webhookNotFoundErrorMessage(path, httpMethod, methods),
WEBHOOK_TEST_UNREGISTERED_HINT,
);
}
@@ -95,8 +97,9 @@ export class TestWebhooks {
// TODO: Clean that duplication up one day and improve code generally
if (testWebhookData[webhookKey] === undefined) {
// The requested webhook is not registered
const methods = await this.getWebhookMethods(path);
throw new ResponseHelper.NotFoundError(
`The requested webhook "${httpMethod} ${path}" is not registered.`,
webhookNotFoundErrorMessage(path, httpMethod, methods),
WEBHOOK_TEST_UNREGISTERED_HINT,
);
}
@@ -160,7 +163,7 @@ export class TestWebhooks {
if (!webhookMethods.length) {
// The requested webhook is not registered
throw new ResponseHelper.NotFoundError(
`The requested webhook "${path}" is not registered.`,
webhookNotFoundErrorMessage(path),
WEBHOOK_TEST_UNREGISTERED_HINT,
);
}