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,