fix(core): Ensure error.message is a string before checking for specific messages (#17417)

This commit is contained in:
Pavel
2025-08-19 16:40:22 +03:00
committed by GitHub
parent 554327ee78
commit 0d4c89058d
9 changed files with 38 additions and 24 deletions

View File

@@ -25,8 +25,8 @@ const {
} = RESPONSE_ERROR_MESSAGES; } = RESPONSE_ERROR_MESSAGES;
const isClientError = (error: Error) => const isClientError = (error: Error) =>
[PACKAGE_VERSION_NOT_FOUND, PACKAGE_DOES_NOT_CONTAIN_NODES, PACKAGE_NOT_FOUND].some((msg) => [PACKAGE_VERSION_NOT_FOUND, PACKAGE_DOES_NOT_CONTAIN_NODES, PACKAGE_NOT_FOUND].some(
error.message.includes(msg), (msg) => typeof error.message === 'string' && error.message.includes(msg),
); );
export function isNpmError(error: unknown): error is { code: number; stdout: string } { export function isNpmError(error: unknown): error is { code: number; stdout: string } {

View File

@@ -58,7 +58,7 @@ export async function restoreBinaryDataId(
const error = e instanceof Error ? e : new Error(`${e}`); const error = e instanceof Error ? e : new Error(`${e}`);
const logger = Container.get(Logger); const logger = Container.get(Logger);
if (error.message.includes('ENOENT')) { if (typeof error.message === 'string' && error.message.includes('ENOENT')) {
logger.warn('Failed to restore binary data ID - No such file or dir', { logger.warn('Failed to restore binary data ID - No such file or dir', {
executionId, executionId,
error, error,

View File

@@ -80,7 +80,7 @@ export class WorkflowRunner {
if ( if (
error instanceof ExecutionNotFoundError || error instanceof ExecutionNotFoundError ||
error instanceof ExecutionCancelledError || error instanceof ExecutionCancelledError ||
error.message.includes('cancelled') (typeof error.message === 'string' && error.message.includes('cancelled'))
) { ) {
return; return;
} }
@@ -422,6 +422,7 @@ export class WorkflowRunner {
} catch (error) { } catch (error) {
if ( if (
error instanceof Error && error instanceof Error &&
typeof error.message === 'string' &&
error.message.includes('job stalled more than maxStalledCount') error.message.includes('job stalled more than maxStalledCount')
) { ) {
error = new MaxStalledCountError(error); error = new MaxStalledCountError(error);

View File

@@ -235,6 +235,7 @@ export class ErrorReporter {
return ( return (
error instanceof Error && error instanceof Error &&
error.name === 'QueryFailedError' && error.name === 'QueryFailedError' &&
typeof error.message === 'string' &&
['SQLITE_FULL', 'SQLITE_IOERR'].some((errMsg) => error.message.includes(errMsg)) ['SQLITE_FULL', 'SQLITE_IOERR'].some((errMsg) => error.message.includes(errMsg))
); );
} }

View File

@@ -206,7 +206,7 @@ export async function generateCodeForAiTransform(prompt: string, path: string, r
code = generatedCode; code = generatedCode;
break; break;
} catch (e) { } catch (e) {
if (e.message.includes('maximum context length')) { if (typeof e.message === 'string' && e.message.includes('maximum context length')) {
reducePayloadSizeOrThrow(payload, e); reducePayloadSizeOrThrow(payload, e);
continue; continue;
} }

View File

@@ -93,7 +93,11 @@ export const useWorkflowHistoryStore = defineStore('workflowHistory', () => {
return await workflowsStore return await workflowsStore
.updateWorkflow(workflowId, updateData, true) .updateWorkflow(workflowId, updateData, true)
.catch(async (error) => { .catch(async (error) => {
if (error.httpStatusCode === 400 && error.message.includes('can not be activated')) { if (
error.httpStatusCode === 400 &&
typeof error.message === 'string' &&
error.message.includes('can not be activated')
) {
return await workflowsStore.fetchWorkflow(workflowId); return await workflowsStore.fetchWorkflow(workflowId);
} else { } else {
throw new Error(error); throw new Error(error);

View File

@@ -161,7 +161,7 @@ export async function execute(
returnData.push(newItem); returnData.push(newItem);
} catch (error) { } catch (error) {
let errorDescription; let errorDescription;
if (error.message.includes('Unexpected token')) { if (typeof error.message === 'string' && error.message.includes('Unexpected token')) {
error.message = "The file selected in 'Input Binary Field' is not in JSON format"; error.message = "The file selected in 'Input Binary Field' is not in JSON format";
errorDescription = errorDescription =
"Try to change the operation or select a JSON file in 'Input Binary Field'"; "Try to change the operation or select a JSON file in 'Input Binary Field'";

View File

@@ -10,6 +10,7 @@ export function errorMapper(
let message; let message;
let description; let description;
if (typeof error.message === 'string') {
if (error.message.includes('Cannot create a string longer than')) { if (error.message.includes('Cannot create a string longer than')) {
message = 'The file is too large'; message = 'The file is too large';
description = description =
@@ -27,6 +28,7 @@ export function errorMapper(
description = description =
"Specify another destination folder in 'File Path and Name', or change the permissions of the parent folder"; "Specify another destination folder in 'File Path and Name', or change the permissions of the parent folder";
} }
}
return new NodeOperationError(this.getNode(), error, { itemIndex, message, description }); return new NodeOperationError(this.getNode(), error, { itemIndex, message, description });
} }

View File

@@ -458,7 +458,13 @@ export function generateNodesGraph(
} }
} }
} catch (e: unknown) { } catch (e: unknown) {
if (!(e instanceof Error && e.message.includes('Unrecognized node type'))) { if (
!(
e instanceof Error &&
typeof e.message === 'string' &&
e.message.includes('Unrecognized node type')
)
) {
throw e; throw e;
} }
} }