From 0408299c7d6fff69b9ac92688fc3e24d980fa59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 17 Nov 2023 10:25:10 +0100 Subject: [PATCH] refactor(core): Stop reporting to Sentry unrecognized node errors (no-changelog) (#7728) https://n8nio.sentry.io/issues/4636584213 --- cypress/e2e/12-canvas.cy.ts | 6 +++--- packages/cli/src/NodeTypes.ts | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/12-canvas.cy.ts b/cypress/e2e/12-canvas.cy.ts index 0d4a0f414e..c7bea8e8c1 100644 --- a/cypress/e2e/12-canvas.cy.ts +++ b/cypress/e2e/12-canvas.cy.ts @@ -390,20 +390,20 @@ describe('Canvas Node Manipulation and Navigation', () => { ); WorkflowPage.actions.executeWorkflow(); - cy.contains('Node not found').should('be.visible'); + cy.contains('Unrecognized node type').should('be.visible'); WorkflowPage.getters .canvasNodeByName(`${unknownNodeName} 1`) .find('[data-test-id=delete-node-button]') .click({ force: true }); - WorkflowPage.getters + WorkflowPage.getters .canvasNodeByName(`${unknownNodeName} 2`) .find('[data-test-id=delete-node-button]') .click({ force: true }); WorkflowPage.actions.executeWorkflow(); - cy.contains('Node not found').should('not.exist'); + cy.contains('Unrecognized node type').should('not.exist'); }); }); diff --git a/packages/cli/src/NodeTypes.ts b/packages/cli/src/NodeTypes.ts index 7831f3bd2c..19b052a208 100644 --- a/packages/cli/src/NodeTypes.ts +++ b/packages/cli/src/NodeTypes.ts @@ -8,12 +8,19 @@ import type { } from 'n8n-workflow'; import { NodeHelpers } from 'n8n-workflow'; import { Service } from 'typedi'; -import { RESPONSE_ERROR_MESSAGES } from './constants'; import { LoadNodesAndCredentials } from './LoadNodesAndCredentials'; import { join, dirname } from 'path'; import { readdir } from 'fs/promises'; import type { Dirent } from 'fs'; +class UnrecognizedNodeError extends Error { + severity = 'warning'; + + constructor(nodeType: string) { + super(`Unrecognized node type: ${nodeType}".`); + } +} + @Service() export class NodeTypes implements INodeTypes { constructor(private loadNodesAndCredentials: LoadNodesAndCredentials) { @@ -67,7 +74,8 @@ export class NodeTypes implements INodeTypes { loadedNodes[type] = { sourcePath, type: loaded }; return loadedNodes[type]; } - throw new Error(`${RESPONSE_ERROR_MESSAGES.NO_NODE}: ${type}`); + + throw new UnrecognizedNodeError(type); } async getNodeTranslationPath({