Build lambda error - catch user code compilation errors (#19516)

Fixes
https://twenty-v7.sentry.io/issues/7335177730/events/latest/?environment=prod&project=4507072499810304&query=is%3Aunresolved&referrer=latest-event

- Provide a more explicit error for user
- Remove from sentry while keeping others due to infra issues
This commit is contained in:
Thomas Trompette
2026-04-09 16:28:27 +00:00
committed by GitHub
parent e411f076f1
commit 00208dbf1f
3 changed files with 20 additions and 0 deletions
@@ -32,6 +32,7 @@ import {
type LogicFunctionTranspileResult,
} from 'src/engine/core-modules/logic-function/logic-function-drivers/interfaces/logic-function-driver.interface';
import { isNonEmptyString } from '@sniptt/guards';
import { ASSET_PATH } from 'src/constants/assets-path';
import { type FlatApplication } from 'src/engine/core-modules/application/types/flat-application.type';
import { type CacheLockService } from 'src/engine/core-modules/cache-lock/cache-lock.service';
@@ -529,6 +530,19 @@ export class LambdaDriver implements LogicFunctionDriver {
? JSON.parse(result.Payload.transformToString())
: {};
const userCompilationErrorRegex = /^Build failed with \d+ error/;
const isUserCompilationError =
isNonEmptyString(parsedResult?.errorMessage) &&
userCompilationErrorRegex.test(parsedResult.errorMessage);
if (isUserCompilationError) {
throw new LogicFunctionException(
`Function code compilation failed: ${parsedResult.errorMessage}`,
LogicFunctionExceptionCode.LOGIC_FUNCTION_COMPILATION_FAILED,
);
}
throw new LogicFunctionException(
`Builder Lambda failed: ${JSON.stringify(parsedResult)}`,
LogicFunctionExceptionCode.LOGIC_FUNCTION_CREATE_FAILED,
@@ -12,6 +12,7 @@ export enum LogicFunctionExceptionCode {
LOGIC_FUNCTION_CODE_UNCHANGED = 'LOGIC_FUNCTION_CODE_UNCHANGED',
LOGIC_FUNCTION_EXECUTION_LIMIT_REACHED = 'LOGIC_FUNCTION_EXECUTION_LIMIT_REACHED',
LOGIC_FUNCTION_CREATE_FAILED = 'LOGIC_FUNCTION_CREATE_FAILED',
LOGIC_FUNCTION_COMPILATION_FAILED = 'LOGIC_FUNCTION_COMPILATION_FAILED',
LOGIC_FUNCTION_EXECUTION_TIMEOUT = 'LOGIC_FUNCTION_EXECUTION_TIMEOUT',
LOGIC_FUNCTION_DISABLED = 'LOGIC_FUNCTION_DISABLED',
LOGIC_FUNCTION_INVALID_SEED_PROJECT = 'LOGIC_FUNCTION_INVALID_SEED_PROJECT',
@@ -35,6 +36,8 @@ const getLogicFunctionExceptionUserFriendlyMessage = (
return msg`Function execution limit reached.`;
case LogicFunctionExceptionCode.LOGIC_FUNCTION_CREATE_FAILED:
return msg`Failed to create function.`;
case LogicFunctionExceptionCode.LOGIC_FUNCTION_COMPILATION_FAILED:
return msg`Function code failed to compile.`;
case LogicFunctionExceptionCode.LOGIC_FUNCTION_EXECUTION_TIMEOUT:
return msg`Function execution timed out.`;
case LogicFunctionExceptionCode.LOGIC_FUNCTION_DISABLED:
@@ -5,6 +5,7 @@ import {
ForbiddenError,
NotFoundError,
TimeoutError,
UserInputError,
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
import {
LogicFunctionException,
@@ -29,6 +30,8 @@ export const logicFunctionGraphQLApiExceptionHandler = (error: any) => {
case LogicFunctionExceptionCode.LOGIC_FUNCTION_CREATE_FAILED:
case LogicFunctionExceptionCode.LOGIC_FUNCTION_INVALID_SEED_PROJECT:
throw error;
case LogicFunctionExceptionCode.LOGIC_FUNCTION_COMPILATION_FAILED:
throw new UserInputError(error);
case LogicFunctionExceptionCode.LOGIC_FUNCTION_DISABLED:
throw new ForbiddenError(error);
default: {