-
Notifications
You must be signed in to change notification settings - Fork 46.2k
fix(GraphQL Node): Prevent duplicate error items in error output routing #20360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 3 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 issues and fix them.
<file name="packages/nodes-base/nodes/GraphQL/GraphQL.node.ts">
<violation number="1" location="packages/nodes-base/nodes/GraphQL/GraphQL.node.ts:519">
The fix to prevent duplicate error outputs introduces a regression where GraphQL errors are no longer handled when the 'Response Format' is set to 'String'. The error detection logic is now skipped for string-based responses, causing them to be incorrectly routed to the success output.</violation>
<violation number="2" location="packages/nodes-base/nodes/GraphQL/GraphQL.node.ts:537">
Rule violated: **Prefer Typeguards over Type casting**
Prefer Typeguards over Type casting §1: instead of casting `response.errors` to JsonObject, validate the GraphQL error payload (e.g., ensure it’s an array of JSON objects and wrap it in a JsonObject) before constructing `NodeApiError`.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
Hey @ongdisheng, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
@cubic-dev-ai review this PR |
@ongdisheng I've started the AI code review. It'll take a few minutes to complete. |
There was a problem hiding this 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 3 files
Summary
This PR fixes an issue where
GraphQL
errors would appear in both the success and error outputs when using the "Continue using error output" setting. The problem occurred because the node was adding theGraphQL
response toreturnItems
before checking for errors. This fix moves the error checking logic before adding items toreturnItems
, ensuring thatGraphQL
errors are only routed to the error output and successful responses only go to the success output.Screenshot
Related Linear tickets, Github issues, and Community forum posts
Closes #20321
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)