From 91881c804a0da19591eeeaad850d516e4a57aa8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 2 Feb 2024 12:22:26 +0100 Subject: [PATCH] fix(core): Ensure AxiosError status always gets copied over to NodeApiError (#8509) --- packages/workflow/package.json | 1 + packages/workflow/src/errors/node-api.error.ts | 5 +++++ pnpm-lock.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/packages/workflow/package.json b/packages/workflow/package.json index 34977f1f5d8cf..d200adca3aa50 100644 --- a/packages/workflow/package.json +++ b/packages/workflow/package.json @@ -51,6 +51,7 @@ "@n8n/tournament": "1.0.2", "@n8n_io/riot-tmpl": "4.0.0", "ast-types": "0.15.2", + "axios": "1.6.7", "callsites": "3.1.0", "deep-equal": "2.2.0", "esprima-next": "5.8.4", diff --git a/packages/workflow/src/errors/node-api.error.ts b/packages/workflow/src/errors/node-api.error.ts index c1dc5c86b0939..5551197c9325b 100644 --- a/packages/workflow/src/errors/node-api.error.ts +++ b/packages/workflow/src/errors/node-api.error.ts @@ -14,6 +14,7 @@ import type { import { NodeError } from './abstract/node.error'; import { removeCircularRefs } from '../utils'; import type { ReportingOptions } from './application.error'; +import { AxiosError } from 'axios'; export interface NodeOperationErrorOptions { message?: string; @@ -127,6 +128,10 @@ export class NodeApiError extends NodeError { ) { super(node, errorResponse); + if (!httpCode && errorResponse instanceof AxiosError) { + httpCode = errorResponse.response?.status?.toString(); + } + // only for request library error if (errorResponse.error) { removeCircularRefs(errorResponse.error as JsonObject); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8ae7586806b9e..4c6c75e4cdd20 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1502,6 +1502,9 @@ importers: ast-types: specifier: 0.15.2 version: 0.15.2 + axios: + specifier: 1.6.7 + version: 1.6.7(debug@3.2.7) callsites: specifier: 3.1.0 version: 3.1.0