13058 workflow with code fail to run (#13118)

- update publishOneServerlessFunction so it does not break the workflow
if failing
- update upgrade documentation to update `docker-compose.yml` when
mutated

Fixes https://github.com/twentyhq/twenty/issues/13058
This commit is contained in:
martmull
2025-07-09 14:48:44 +02:00
committed by GitHub
parent e84521e7b8
commit 156cb1b52f
5 changed files with 41 additions and 36 deletions

View File

@ -163,7 +163,7 @@ export class ServerlessFunctionResolver {
try {
const { id } = input;
return await this.serverlessFunctionService.publishOneServerlessFunction(
return await this.serverlessFunctionService.publishOneServerlessFunctionOrFail(
id,
workspaceId,
);

View File

@ -30,6 +30,10 @@ import {
ServerlessFunctionException,
ServerlessFunctionExceptionCode,
} from 'src/engine/metadata-modules/serverless-function/serverless-function.exception';
import {
WorkflowVersionStepException,
WorkflowVersionStepExceptionCode,
} from 'src/modules/workflow/common/exceptions/workflow-version-step.exception';
@Injectable()
export class ServerlessFunctionService {
@ -137,7 +141,7 @@ export class ServerlessFunctionService {
return resultServerlessFunction;
}
async publishOneServerlessFunction(id: string, workspaceId: string) {
async publishOneServerlessFunctionOrFail(id: string, workspaceId: string) {
const existingServerlessFunction =
await this.serverlessFunctionRepository.findOneOrFail({
where: {
@ -159,10 +163,7 @@ export class ServerlessFunctionService {
);
if (deepEqual(latestCode, draftCode)) {
throw new ServerlessFunctionException(
'Cannot publish a new version when code has not changed',
ServerlessFunctionExceptionCode.SERVERLESS_FUNCTION_CODE_UNCHANGED,
);
return existingServerlessFunction;
}
}
@ -174,6 +175,7 @@ export class ServerlessFunctionService {
serverlessFunction: existingServerlessFunction,
version: 'draft',
});
const newFolderPath = getServerlessFolder({
serverlessFunction: existingServerlessFunction,
version: newVersion,
@ -197,9 +199,26 @@ export class ServerlessFunctionService {
},
);
return this.serverlessFunctionRepository.findOneBy({
id: existingServerlessFunction.id,
});
const publishedServerlessFunction =
await this.serverlessFunctionRepository.findOneOrFail({
where: {
id,
workspaceId,
},
});
// This check should never be thrown, but we encounter some issue with
// publishing serverless function in self hosted instances
// See https://github.com/twentyhq/twenty/issues/13058
// TODO: remove this check when issue solved
if (!isDefined(publishedServerlessFunction.latestVersion)) {
throw new WorkflowVersionStepException(
`Fail to publish serverlessFunction ${publishedServerlessFunction.id}.Received latest version ${publishedServerlessFunction.latestVersion}`,
WorkflowVersionStepExceptionCode.FAILURE,
);
}
return publishedServerlessFunction;
}
async deleteOneServerlessFunction({