Skip to content

Conversation

@DawidMyslak
Copy link
Contributor

@DawidMyslak DawidMyslak commented Dec 8, 2025

Summary

The @feature display condition allows you to show or hide node parameters based on feature flags defined in the node type description. This provides a declarative way to control parameter visibility based on node version and feature availability. The isNodeFeatureEnabled method allows you to execute code based on the feature being enabled or disabled.

Feature Definition

Feature flags are defined in the features object of a node type description and evaluated based on the node's version:

const description: INodeTypeDescription = {
  // ... other properties
  version: [2, 2.1, 2.2, 2.3, 2.4],
  features: {
    useFeatureA: { '@version': [{ _cnd: { gte: 2.4 } }] }, // Enabled in v2.4+
    useFeatureB: { '@version': [{ _cnd: { lte: 2.1 } }] }, // Enabled in v2.1 and below
    useFeatureC: { '@version': [{ _cnd: { gte: 2.2 } }] }, // Enabled in v2.2+
    useFeatureD: { '@version': [2] }, // Enabled only in v2
    useFeatureE: { '@version': [{ _cnd: { lt: 2.3 } }] }, // Enabled below v2.3
  },
  // ... rest of description
};

Usage in Code

The isNodeFeatureEnabled method is available in node execution contexts (like IExecuteFunctions, IWebhookFunctions, etc.) to programmatically check if a feature is enabled.

export async function execute(this: IExecuteFunctions) {
  // Check if a feature is enabled
  if (this.isNodeFeatureEnabled('useFeatureA')) {
    // Process with feature enabled
  } else {
    // Process with feature disabled
  }
}

Usage in displayOptions

Simple String Array

The simplest form checks if a feature is enabled:

{
  displayName: 'Field Name',
  name: 'fieldName',
  type: 'string',
  displayOptions: {
    show: {
      '@feature': ['useFeatureA'], // Show if useFeatureA is enabled
    },
  },
}

Condition Syntax with eq (Equals)

Check if a feature is enabled using the condition syntax:

{
  displayName: 'Field Name',
  name: 'fieldName',
  type: 'string',
  displayOptions: {
    show: {
      '@feature': [{ _cnd: { eq: 'useFeatureA' } }], // Show if useFeatureA is enabled
    },
  },
}

Condition Syntax with not (Not Equals)

Check if a feature is disabled:

{
  displayName: 'Field Label',
  name: 'fieldLabel',
  type: 'string',
  displayOptions: {
    show: {
      '@feature': [{ _cnd: { not: 'useFeatureA' } }], // Show if useFeatureA is NOT enabled
    },
  },
}

Multiple Conditions (OR Logic)

Show a parameter if any of the features match:

{
  displayName: 'Path',
  name: 'path',
  type: 'string',
  displayOptions: {
    show: {
      '@feature': [
        { _cnd: { eq: 'useFeatureB' } },
        { _cnd: { eq: 'useFeatureC' } },
      ], // Show if either feature is enabled
    },
  },
}

Combining with Other Conditions

You can combine @feature with other display conditions:

{
  displayName: 'Response Mode',
  name: 'responseMode',
  type: 'options',
  displayOptions: {
    show: {
      agent: ['sqlAgent'],
      '@feature': [{ _cnd: { eq: 'useFeatureC' } }],
      '@version': [{ _cnd: { gte: 2.2 } }],
    },
  },
}

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-4065/node-features

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@DawidMyslak DawidMyslak changed the title Node feature based versioning Node features Dec 8, 2025
@DawidMyslak DawidMyslak changed the title Node features feat(core): Node features Dec 8, 2025
@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 91.42857% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/workflow/src/node-helpers.ts 89.65% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Dec 8, 2025
@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@currents-bot
Copy link

currents-bot bot commented Dec 8, 2025

E2E Tests: n8n tests passed after 9m 54s

🟢 576 · 🔴 0 · ⚪️ 43 · 🟣 3

View Run Details

Run Details

  • Project: n8n

  • Groups: 2

  • Framework: Playwright

  • Run Status: Passed

  • Commit: 7497406

  • Spec files: 129

  • Overall tests: 619

  • Duration: 9m 54s

  • Parallelization: 9

Groups

GroupId Results Spec Files Progress
multi-main:ui 🟢 519 · 🔴 0 · ⚪️ 43 · 🟣 3 120 / 120
multi-main:ui:isolated 🟢 57 · 🔴 0 · ⚪️ 0 9 / 9


This message was posted automatically by currents.dev | Integration Settings

@DawidMyslak DawidMyslak marked this pull request as ready for review December 8, 2025 22:31
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files

@Joffcom Joffcom requested a review from elsmr December 9, 2025 08:10
@DawidMyslak DawidMyslak changed the title feat(core): Node features feat(core): Node feature flags Dec 9, 2025
Comment on lines +188 to +190
isNodeFeatureEnabled(featureName: string): boolean {
return this.nodeFeatures[featureName] ?? false;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, maybe a shorter version like isFeatureEnabled or isNodeFeatureOn would be better?

I'm just afraid that isFeatureEnabled might be too generic and some users might think it's related to global feature flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants