fix: Fix issue with some errors not being handled correctly (no-changelog) (#10371)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions

This commit is contained in:
Jon 2024-08-13 18:09:07 +01:00 committed by GitHub
parent 8e7d29ad3c
commit 1e310f40f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View file

@ -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 === 'string' && COMMON_ERRORS[code.toUpperCase()]) {
newMessage = COMMON_ERRORS[code] as string;
messages.push(message);
return [newMessage, messages];

View file

@ -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';
@ -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);
});
});