mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-21 12:51:16 +08:00
fix(core): Reject empty webhookMethods in community lint rule (#29474)
This commit is contained in:
+5
@@ -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({
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user