Skip to content

Conversation

cstuncsik
Copy link
Contributor

@cstuncsik cstuncsik commented Sep 1, 2025

Summary

Fixing the root cause of why getParentMainInputNode had to check if the node output is an array, despite the types definition tells it's always an array.

Related Linear tickets, Github issues, and Community forum posts

PAY-3738

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)

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Sep 1, 2025
Copy link

codecov bot commented Sep 1, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.

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

📢 Thoughts on this report? Let us know!

@cstuncsik cstuncsik marked this pull request as ready for review September 2, 2025 09:43
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 2 files

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

) || []) as NodeConnectionType[];
);
outputs = Array.isArray(result)
? (result as Array<NodeConnectionType | INodeOutputConfiguration>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rule violated: Prefer Typeguards over Type casting

Avoid using a type assertion for narrowing here. Introduce a type guard (e.g., isOutputsArray) to validate result’s element types, then assign after narrowing instead of (result as ...).

(Based on your team's feedback about avoiding '(...) as T[]' casts and replacing them with explicit type guards that check the response shape before narrowing.)

Prompt for AI agents
Address the following comment on packages/workflow/src/node-helpers.ts at line 1057:

<comment>Avoid using a type assertion for narrowing here. Introduce a type guard (e.g., isOutputsArray) to validate result’s element types, then assign after narrowing instead of `(result as ...)`.

(Based on your team&#39;s feedback about avoiding &#39;(...) as T[]&#39; casts and replacing them with explicit type guards that check the response shape before narrowing.)</comment>

<file context>
@@ -1047,12 +1047,15 @@ export function getNodeOutputs(
-			) || []) as NodeConnectionType[];
+			);
+			outputs = Array.isArray(result)
+				? (result as Array&lt;NodeConnectionType | INodeOutputConfiguration&gt;)
+				: [];
 		} catch (e) {
</file context>

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.

1 participant