mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 18:41:14 +00:00
fix(core): Validate node name when creating NodeOperationErrror (#11999)
This commit is contained in:
@@ -52,7 +52,7 @@ import type { IWorkflowErrorData, UpdateExecutionPayload } from '@/interfaces';
|
||||
import { NodeTypes } from '@/node-types';
|
||||
import { Push } from '@/push';
|
||||
import { WorkflowStatisticsService } from '@/services/workflow-statistics.service';
|
||||
import { findSubworkflowStart, isWorkflowIdValid } from '@/utils';
|
||||
import { findSubworkflowStart, isObjectLiteral, isWorkflowIdValid } from '@/utils';
|
||||
import * as WorkflowHelpers from '@/workflow-helpers';
|
||||
|
||||
import { WorkflowRepository } from './databases/repositories/workflow.repository';
|
||||
@@ -80,11 +80,20 @@ export function objectToError(errorObject: unknown, workflow: Workflow): Error {
|
||||
if (errorObject instanceof Error) {
|
||||
// If it's already an Error instance, return it as is.
|
||||
return errorObject;
|
||||
} else if (errorObject && typeof errorObject === 'object' && 'message' in errorObject) {
|
||||
} else if (
|
||||
isObjectLiteral(errorObject) &&
|
||||
'message' in errorObject &&
|
||||
typeof errorObject.message === 'string'
|
||||
) {
|
||||
// If it's an object with a 'message' property, create a new Error instance.
|
||||
let error: Error | undefined;
|
||||
if ('node' in errorObject) {
|
||||
const node = workflow.getNode((errorObject.node as { name: string }).name);
|
||||
if (
|
||||
'node' in errorObject &&
|
||||
isObjectLiteral(errorObject.node) &&
|
||||
typeof errorObject.node.name === 'string'
|
||||
) {
|
||||
const node = workflow.getNode(errorObject.node.name);
|
||||
|
||||
if (node) {
|
||||
error = new NodeOperationError(
|
||||
node,
|
||||
@@ -95,7 +104,7 @@ export function objectToError(errorObject: unknown, workflow: Workflow): Error {
|
||||
}
|
||||
|
||||
if (error === undefined) {
|
||||
error = new Error(errorObject.message as string);
|
||||
error = new Error(errorObject.message);
|
||||
}
|
||||
|
||||
if ('description' in errorObject) {
|
||||
|
||||
Reference in New Issue
Block a user