From 34d7a02df73f233ef55fc78e3ea8167bc2b32a1f Mon Sep 17 00:00:00 2001 From: Chris Z <535257617@qq.com> Date: Mon, 4 May 2026 15:11:24 +0800 Subject: [PATCH] fix(core): Reject empty webhookMethods in community lint rule (#29474) --- .../src/rules/webhook-lifecycle-complete.test.ts | 5 +++++ .../src/rules/webhook-lifecycle-complete.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.test.ts b/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.test.ts index 7bb10dab3ee..885d3bc3e17 100644 --- a/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.test.ts +++ b/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.test.ts @@ -107,6 +107,11 @@ export class RegularClass { code: createTriggerNode({ webhookMethods: null }), errors: [{ messageId: 'missingWebhookMethods' }], }, + { + name: 'trigger node with empty webhookMethods object (no lifecycle groups)', + code: createTriggerNode({ webhookMethods: '{}' }), + errors: [{ messageId: 'emptyWebhookMethods' }], + }, { name: 'trigger node with empty webhookMethods group (all three missing)', code: createTriggerNode({ diff --git a/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.ts b/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.ts index 475d086e966..f36dffe54ca 100644 --- a/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.ts +++ b/packages/@n8n/eslint-plugin-community-nodes/src/rules/webhook-lifecycle-complete.ts @@ -56,6 +56,8 @@ export const WebhookLifecycleCompleteRule = createRule({ messages: { missingWebhookMethods: 'Webhook trigger node is missing the `webhookMethods` property. Implement `checkExists`, `create`, and `delete` to register, verify, and clean up the webhook on the third-party service.', + emptyWebhookMethods: + 'Webhook trigger node has an empty `webhookMethods` object. Define at least one lifecycle group with `checkExists`, `create`, and `delete` methods.', missingLifecycleMethod: 'Webhook trigger lifecycle is incomplete. `webhookMethods.{{group}}` is missing: {{missing}}. All of `checkExists`, `create`, and `delete` must be implemented.', }, @@ -91,6 +93,14 @@ export const WebhookLifecycleCompleteRule = createRule({ return; } + if (webhookMethodsProperty.value.properties.length === 0) { + context.report({ + node: webhookMethodsProperty.key, + messageId: 'emptyWebhookMethods', + }); + return; + } + for (const groupProperty of webhookMethodsProperty.value.properties) { if (groupProperty.type !== AST_NODE_TYPES.Property) continue; if (groupProperty.value.type !== AST_NODE_TYPES.ObjectExpression) continue;