diff --git a/packages/workflow/src/errors/abstract/node.error.ts b/packages/workflow/src/errors/abstract/node.error.ts index 460538fc0e..5d679507c7 100644 --- a/packages/workflow/src/errors/abstract/node.error.ts +++ b/packages/workflow/src/errors/abstract/node.error.ts @@ -167,7 +167,7 @@ export abstract class NodeError extends ExecutionBaseError { } // if code is provided and it is in the list of common errors set the message and return early - if (code && COMMON_ERRORS[code.toUpperCase()]) { + if (code && typeof code === 'string' && COMMON_ERRORS[code.toUpperCase()]) { newMessage = COMMON_ERRORS[code] as string; messages.push(message); return [newMessage, messages]; diff --git a/packages/workflow/test/NodeErrors.test.ts b/packages/workflow/test/NodeErrors.test.ts index 405c591932..12033fd28d 100644 --- a/packages/workflow/test/NodeErrors.test.ts +++ b/packages/workflow/test/NodeErrors.test.ts @@ -1,4 +1,4 @@ -import type { INode } from '@/Interfaces'; +import type { INode, JsonObject } from '@/Interfaces'; import { NodeOperationError } from '@/errors'; import { NodeApiError } from '@/errors/node-api.error'; import { UNKNOWN_ERROR_DESCRIPTION, UNKNOWN_ERROR_MESSAGE } from '../src/Constants'; @@ -260,4 +260,22 @@ describe('NodeApiError message and description logic', () => { expect(nodeApiError.message).toEqual(UNKNOWN_ERROR_MESSAGE); expect(nodeApiError.description).toEqual(UNKNOWN_ERROR_DESCRIPTION); }); + + it('case: Error code sent as "any"', () => { + const error = { + code: 400, + message: "Invalid value 'test' for viewId parameter.", + status: 'INVALID_ARGUMENT', + }; + const [message, ...rest] = error.message.split('\n'); + const description = rest.join('\n'); + const httpCode = error.code as any; + const nodeApiError = new NodeApiError(node, error as JsonObject, { + message, + description, + httpCode, + }); + + expect(nodeApiError.message).toEqual(error.message); + }); });