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: Fix issue with some errors not being handled correctly (no-changelog) #10371

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion packages/workflow/src/errors/abstract/node.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export abstract class NodeError extends ExecutionBaseError {
}

// if code is provided and it is in the list of common errors set the message and return early
if (code && COMMON_ERRORS[code.toUpperCase()]) {
if (code && typeof code !== 'number' && COMMON_ERRORS[code.toUpperCase()]) {
Joffcom marked this conversation as resolved.
Show resolved Hide resolved
newMessage = COMMON_ERRORS[code] as string;
messages.push(message);
return [newMessage, messages];
Expand Down
20 changes: 19 additions & 1 deletion packages/workflow/test/NodeErrors.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { INode } from '@/Interfaces';
import type { INode, JsonObject } from '@/Interfaces';
import { NodeOperationError } from '@/errors';
import { NodeApiError } from '@/errors/node-api.error';
import { UNKNOWN_ERROR_DESCRIPTION, UNKNOWN_ERROR_MESSAGE } from '../src/Constants';
Expand Down Expand Up @@ -260,4 +260,22 @@ describe('NodeApiError message and description logic', () => {
expect(nodeApiError.message).toEqual(UNKNOWN_ERROR_MESSAGE);
expect(nodeApiError.description).toEqual(UNKNOWN_ERROR_DESCRIPTION);
});

it('case: Error code sent as "any"', () => {
const error = {
code: 400,
message: "Invalid value 'test' for viewId parameter.",
status: 'INVALID_ARGUMENT',
};
const [message, ...rest] = error.message.split('\n');
const description = rest.join('\n');
const httpCode = error.code as any;
const nodeApiError = new NodeApiError(node, error as JsonObject, {
message,
description,
httpCode,
});

expect(nodeApiError.message).toEqual(error.message);
});
});