mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 03:12:15 +00:00
feat(editor): Expose View Execution links for erroneous sub-executions (#13185)
This commit is contained in:
31
packages/workflow/src/MetadataUtils.ts
Normal file
31
packages/workflow/src/MetadataUtils.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import type { ITaskMetadata } from '.';
|
||||
import { hasKey } from './utils';
|
||||
|
||||
function responseHasSubworkflowData(
|
||||
response: unknown,
|
||||
): response is { executionId: string; workflowId: string } {
|
||||
return ['executionId', 'workflowId'].every(
|
||||
(x) => hasKey(response, x) && typeof response[x] === 'string',
|
||||
);
|
||||
}
|
||||
|
||||
type ISubWorkflowMetadata = Required<Pick<ITaskMetadata, 'subExecution' | 'subExecutionsCount'>>;
|
||||
|
||||
function parseErrorResponseWorkflowMetadata(response: unknown): ISubWorkflowMetadata | undefined {
|
||||
if (!responseHasSubworkflowData(response)) return undefined;
|
||||
|
||||
return {
|
||||
subExecution: {
|
||||
executionId: response.executionId,
|
||||
workflowId: response.workflowId,
|
||||
},
|
||||
subExecutionsCount: 1,
|
||||
};
|
||||
}
|
||||
|
||||
export function parseErrorMetadata(error: unknown): ISubWorkflowMetadata | undefined {
|
||||
if (hasKey(error, 'errorResponse')) {
|
||||
return parseErrorResponseWorkflowMetadata(error.errorResponse);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import type {
|
||||
IDataObject,
|
||||
IStatusCodeMessages,
|
||||
Functionality,
|
||||
RelatedExecution,
|
||||
} from '../Interfaces';
|
||||
import { removeCircularRefs } from '../utils';
|
||||
|
||||
@@ -30,6 +31,10 @@ export interface NodeOperationErrorOptions {
|
||||
messageMapping?: { [key: string]: string }; // allows to pass custom mapping for error messages scoped to a node
|
||||
functionality?: Functionality;
|
||||
type?: string;
|
||||
metadata?: {
|
||||
subExecution?: RelatedExecution;
|
||||
parentExecution?: RelatedExecution;
|
||||
};
|
||||
}
|
||||
|
||||
interface NodeApiErrorOptions extends NodeOperationErrorOptions {
|
||||
|
||||
@@ -35,6 +35,7 @@ export class NodeOperationError extends NodeError {
|
||||
this.description = options.description;
|
||||
this.context.runIndex = options.runIndex;
|
||||
this.context.itemIndex = options.itemIndex;
|
||||
this.context.metadata = options.metadata;
|
||||
|
||||
if (this.message === this.description) {
|
||||
this.description = undefined;
|
||||
|
||||
@@ -15,6 +15,7 @@ export * from './ExecutionStatus';
|
||||
export * from './Expression';
|
||||
export * from './FromAIParseUtils';
|
||||
export * from './NodeHelpers';
|
||||
export * from './MetadataUtils';
|
||||
export * from './Workflow';
|
||||
export * from './WorkflowDataProxy';
|
||||
export * from './WorkflowDataProxyEnvProvider';
|
||||
|
||||
@@ -276,3 +276,10 @@ export function randomString(minLength: number, maxLength?: number): string {
|
||||
.map((byte) => ALPHABET[byte % ALPHABET.length])
|
||||
.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a value is an object with a specific key and provides a type guard for the key.
|
||||
*/
|
||||
export function hasKey<T extends PropertyKey>(value: unknown, key: T): value is Record<T, unknown> {
|
||||
return value !== null && typeof value === 'object' && value.hasOwnProperty(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user