Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Ensure AxiosError status always gets copied over to NodeApiError #8509

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions packages/workflow/src/errors/node-api.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -127,6 +128,10 @@ export class NodeApiError extends NodeError {
) {
super(node, errorResponse);

if (!httpCode && errorResponse instanceof AxiosError) {
httpCode = errorResponse.response?.status?.toString();
}
Comment on lines +131 to +133
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be found down below? Why is that not working?

// set http code of this error
if (httpCode) {
	this.httpCode = httpCode;
} else {
	this.httpCode =
		this.findProperty(errorResponse, ERROR_STATUS_PROPERTIES, ERROR_NESTING_PROPERTIES) ?? null;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is here is the typing on errorResponse makes this very combersome to understand. maybe we can merge this change for now, and revisit refactoring the typings for NodeApiError / NodeError, so that we clearly distinguish between errors and json error responses.


// only for request library error
if (errorResponse.error) {
removeCircularRefs(errorResponse.error as JsonObject);
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading