mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix(core)!: Allow syntax errors and expression errors to fail executions (#6352)
* fix: Unify expression error behavior for v1 * fix: Add `package.json` to `tsconfig.build.json` * fix: Make `isFrontend` a constant * fix: Use CommonJS require to read version * fix: Use `JSON.parse()` and `fs.readFileSync()` * feat(editor): Make WF name a link on /executions (#6354) * make wf name a link in exec view * link color * make wf name a link in exec view * link color --------- Co-authored-by: Alex Grozav <alex@grozav.com> * fix: Try restoring inclusions in tsconfig files * fix: Try with copy * refactor: Switch base branch and remove global toggle * chore: Remove unrelated changes * chore: Restore lockfile * fix: Ensure all expression errors fail executions * uncaught ExpressionErrors should not fail e2e tests --------- Co-authored-by: romainminaud <romain.minaud@gmail.com> Co-authored-by: Alex Grozav <alex@grozav.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
committed by
कारतोफ्फेलस्क्रिप्ट™
parent
8c008f5d22
commit
1197811a1e
@@ -22,21 +22,14 @@ import type { Workflow } from './Workflow';
|
||||
import { extend, extendOptional } from './Extensions';
|
||||
import { extendedFunctions } from './Extensions/ExtendedFunctions';
|
||||
import { extendSyntax } from './Extensions/ExpressionExtension';
|
||||
import { isExpressionError, IS_FRONTEND, isSyntaxError, isTypeError } from './utils';
|
||||
|
||||
// Set it to use double curly brackets instead of single ones
|
||||
tmpl.brackets.set('{{ }}');
|
||||
|
||||
// Make sure that error get forwarded
|
||||
tmpl.tmpl.errorHandler = (error: Error) => {
|
||||
if (error instanceof ExpressionError) {
|
||||
if (error.context.failExecution) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (typeof process === 'undefined' && error.clientOnly) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
if (isExpressionError(error)) throw error;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
@@ -332,35 +325,11 @@ export class Expression {
|
||||
);
|
||||
return tmpl.tmpl(expression, data);
|
||||
} catch (error) {
|
||||
if (error instanceof ExpressionError) {
|
||||
// Ignore all errors except if they are ExpressionErrors and they are supposed
|
||||
// to fail the execution
|
||||
if (error.context.failExecution) {
|
||||
throw error;
|
||||
}
|
||||
if (isExpressionError(error)) throw error;
|
||||
|
||||
if (typeof process === 'undefined' && error.clientOnly) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
if (isSyntaxError(error)) throw new Error('invalid syntax');
|
||||
|
||||
// Syntax errors resolve to `Error` on the frontend and `null` on the backend.
|
||||
// This is a temporary divergence in evaluation behavior until we make the
|
||||
// breaking change to allow syntax errors to fail executions.
|
||||
if (
|
||||
typeof process === 'undefined' &&
|
||||
error instanceof Error &&
|
||||
error.name === 'SyntaxError'
|
||||
) {
|
||||
throw new Error('invalid syntax');
|
||||
}
|
||||
|
||||
if (
|
||||
typeof process === 'undefined' &&
|
||||
error instanceof Error &&
|
||||
error.name === 'TypeError' &&
|
||||
error.message.endsWith('is not a function')
|
||||
) {
|
||||
if (isTypeError(error) && IS_FRONTEND && error.message.endsWith('is not a function')) {
|
||||
const match = error.message.match(/(?<msg>[^.]+is not a function)/);
|
||||
|
||||
if (!match?.groups?.msg) return null;
|
||||
@@ -373,6 +342,7 @@ export class Expression {
|
||||
value: fnConstructors.async,
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user