mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-21 12:51:16 +08:00
fix(core): Allow details field in continueErrorOutput mode (backport to release-candidate/2.35.x) (#36228)
Co-authored-by: yehorkardash <yehor.kardash@n8n.io>
This commit is contained in:
co-authored by
yehorkardash
parent
66ba995eed
commit
e58a68016b
@@ -1789,6 +1789,43 @@ describe('WorkflowExecute', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test.each([
|
||||
{
|
||||
name: 'details',
|
||||
json: { error: 'Error occurred', details: { httpCode: '500' } },
|
||||
},
|
||||
{
|
||||
name: 'message and details',
|
||||
json: {
|
||||
error: 'Error occurred',
|
||||
message: 'Error details',
|
||||
details: { httpCode: '500' },
|
||||
},
|
||||
},
|
||||
])('should handle error in json with $name properties', ({ json }) => {
|
||||
const nodeSuccessData: INodeExecutionData[][] = [
|
||||
[
|
||||
{
|
||||
json,
|
||||
pairedItem: { item: 0, input: 0 },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
workflowExecute.handleNodeErrorOutput(workflow, executionData, nodeSuccessData, 0);
|
||||
|
||||
expect(nodeSuccessData[0]).toEqual([]);
|
||||
expect(nodeSuccessData[1]).toEqual([
|
||||
{
|
||||
json: {
|
||||
...json,
|
||||
someData: 'test',
|
||||
},
|
||||
pairedItem: { item: 0, input: 0 },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('should preserve pairedItem data when routing errors', () => {
|
||||
const nodeSuccessData: INodeExecutionData[][] = [
|
||||
[
|
||||
|
||||
@@ -2755,9 +2755,10 @@ export class WorkflowExecute {
|
||||
let errorData: GenericValue | undefined;
|
||||
if (item.error) {
|
||||
errorData = item.error;
|
||||
} else if (item.json.error && Object.keys(item.json).length === 1) {
|
||||
errorData = item.json.error;
|
||||
} else if (item.json.error && item.json.message && Object.keys(item.json).length === 2) {
|
||||
} else if (
|
||||
item.json.error &&
|
||||
Object.keys(item.json).every((key) => ['error', 'message', 'details'].includes(key))
|
||||
) {
|
||||
errorData = item.json.error;
|
||||
}
|
||||
|
||||
|
||||
@@ -783,6 +783,7 @@ describe('HttpRequestV3', () => {
|
||||
},
|
||||
pairedItem: { item: 0 },
|
||||
});
|
||||
expect(Object.keys(result[0][0].json)).toEqual(['error', 'details']);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -1702,6 +1702,10 @@ export interface INodeExecutionData {
|
||||
| number
|
||||
| string
|
||||
| undefined;
|
||||
/**
|
||||
* JSON output.
|
||||
* In `continueErrorOutput` mode, engine will try to read item.error or fallback to item.json.error with allowed optional keys: message, details.
|
||||
*/
|
||||
json: IDataObject;
|
||||
binary?: IBinaryKeyData;
|
||||
error?: NodeApiError | NodeOperationError;
|
||||
|
||||
Reference in New Issue
Block a user