Skip to content

Conversation

ShireenMissi
Copy link
Contributor

Summary

Updates Switch node to version 3.3 with noDataExpression: true for the "Number of Outputs" parameter to prevent
expression input while maintaining backward compatibility for earlier versions.

Changes:

  • Added version 3.3 to supported versions array
  • Created version-conditional parameter definitions using @Version display conditions
  • Added tests

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/NODE-3568/community-issue-switch-node-in-expression-mode-outputs-not-visible-in
Closes #18860

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)

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.

1 issue found across 3 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.


describe('Version-specific behavior', () => {
it('should have two numberOutputs parameters with different version conditions', () => {
const baseDescription: INodeTypeBaseDescription = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate baseDescription setup across tests; define it once in the describe scope to reduce repetition and ease maintenance.

Prompt for AI agents
Address the following comment on packages/nodes-base/nodes/Switch/V3/test/switch.node.test.ts at line 11:

<comment>Duplicate baseDescription setup across tests; define it once in the describe scope to reduce repetition and ease maintenance.</comment>

<file context>
@@ -1,5 +1,72 @@
+
+	describe(&#39;Version-specific behavior&#39;, () =&gt; {
+		it(&#39;should have two numberOutputs parameters with different version conditions&#39;, () =&gt; {
+			const baseDescription: INodeTypeBaseDescription = {
+				displayName: &#39;Switch&#39;,
+				name: &#39;n8n-nodes-base.switch&#39;,
</file context>

@ShireenMissi
Copy link
Contributor Author

@claude review

Copy link
Contributor

claude bot commented Sep 1, 2025

Claude finished @ShireenMissi's task —— View job


Code Review Complete ✅

Todo List:

  • Read and analyze the changed files
  • Review the Switch node main file changes
  • Review the V3 implementation changes
  • Review the test implementation and address duplicate code concern
  • Check version handling and backward compatibility
  • Provide comprehensive review feedback

Review Summary

This PR successfully addresses the Switch Node expression mode visibility issue by implementing version 3.3 with noDataExpression: true for the "Number of Outputs" parameter. The solution is well-architected and maintains backward compatibility.

✅ Positive Aspects

  1. Clean Version Management: Proper use of version 3.3 in Switch.node.ts:17 with defaultVersion: 3.3
  2. Smart Backward Compatibility: Dual parameter definitions in SwitchV3.node.ts:83-109 using @version display conditions
  3. Targeted Fix: noDataExpression: true on lines 87 and 91-92 specifically addresses the expression mode visibility issue
  4. Good Test Coverage: Tests verify both the presence of dual parameters and the noDataExpression property
  5. Minimal Impact: Only 3 files changed with focused modifications

🔧 Issues Found

1. Test Code Duplication (Medium Priority)

Location: packages/nodes-base/nodes/Switch/V3/test/switch.node.test.ts:11-16, 27-32, 43-49, 61-66

The baseDescription object is duplicated across all test cases. This creates maintenance overhead.

Recommendation:

describe('Version-specific behavior', () => {
  const baseDescription: INodeTypeBaseDescription = {
    displayName: 'Switch',
    name: 'n8n-nodes-base.switch',
    group: ['transform'],
    description: 'Route items to different outputs',
  };

  it('should have two numberOutputs parameters with different version conditions', () => {
    const switchNode = new SwitchV3(baseDescription);
    // rest of test...
  });
  // other tests...
});

2. Minor Documentation Gap

The parameter descriptions (lines 95, 108) are identical but could clarify the version-specific behavior difference.

🔍 Technical Analysis

Version Handling ✅

  • Correct version array: [3, 3.1, 3.2, 3.3] in line 55
  • Proper conditional logic using @version with gte: 3.3 and lt: 3.3
  • Maintains all existing functionality for older versions

Implementation Pattern ✅

  • Follows n8n's established version-conditional parameter pattern
  • Uses noDataExpression: true correctly to disable expression input
  • Preserves existing execution logic without changes

Test Quality ✅

  • Tests verify the core functionality: dual parameters, noDataExpression property, and version support
  • Tests are comprehensive despite the code duplication issue

🎯 Final Recommendation

APPROVE with minor refactoring suggestion. The PR effectively solves the reported issue and maintains excellent backward compatibility. The test duplication is a code quality improvement opportunity but doesn't block the fix.

💡 Suggested Follow-ups

  1. Refactor test code to eliminate duplication
  2. Consider adding integration tests for actual expression mode behavior
  3. Update node documentation to clarify version differences

Copy link

codecov bot commented Sep 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team node/improvement New feature or request labels Sep 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team node/improvement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch Node in Expression Mode: Outputs Not Visible in Diagram
1 participant