mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(editor): Improve sub-workflow debugging for more node error types (#14347)
This commit is contained in:
@@ -27,5 +27,8 @@ export function parseErrorMetadata(error: unknown): ISubWorkflowMetadata | undef
|
||||
if (hasKey(error, 'errorResponse')) {
|
||||
return parseErrorResponseWorkflowMetadata(error.errorResponse);
|
||||
}
|
||||
return undefined;
|
||||
|
||||
// This accounts for cases where the backend attaches the properties on plain errors
|
||||
// e.g. from custom nodes throwing literal `Error` or `ApplicationError` objects directly
|
||||
return parseErrorResponseWorkflowMetadata(error);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,38 @@ import { parseErrorMetadata } from '@/MetadataUtils';
|
||||
|
||||
describe('MetadataUtils', () => {
|
||||
describe('parseMetadataFromError', () => {
|
||||
it('should return undefined if error does not have response', () => {
|
||||
const expectedMetadata = {
|
||||
subExecution: {
|
||||
executionId: '123',
|
||||
workflowId: '456',
|
||||
},
|
||||
subExecutionsCount: 1,
|
||||
};
|
||||
|
||||
it('should return undefined if error does not have response or both keys on the object', () => {
|
||||
const error = { message: 'An error occurred' };
|
||||
const result = parseErrorMetadata(error);
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if errorResponse only has workflowId key', () => {
|
||||
const error = { errorResponse: { executionId: '123' } };
|
||||
const result = parseErrorMetadata(error);
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return undefined if error only has executionId key', () => {
|
||||
const error = { executionId: '123' };
|
||||
const result = parseErrorMetadata(error);
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should support executionId and workflowId key directly on the error object', () => {
|
||||
const error = { executionId: '123', workflowId: '456' };
|
||||
const result = parseErrorMetadata(error);
|
||||
expect(result).toEqual(expectedMetadata);
|
||||
});
|
||||
|
||||
it('should return undefined if error response does not have subworkflow data', () => {
|
||||
const error = { errorResponse: { someKey: 'someValue' } };
|
||||
const result = parseErrorMetadata(error);
|
||||
@@ -16,13 +42,6 @@ describe('MetadataUtils', () => {
|
||||
|
||||
it('should return metadata if error response has subworkflow data', () => {
|
||||
const error = { errorResponse: { executionId: '123', workflowId: '456' } };
|
||||
const expectedMetadata = {
|
||||
subExecution: {
|
||||
executionId: '123',
|
||||
workflowId: '456',
|
||||
},
|
||||
subExecutionsCount: 1,
|
||||
};
|
||||
const result = parseErrorMetadata(error);
|
||||
expect(result).toEqual(expectedMetadata);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user