Allow webhook only on active versions (#11705)

- webhook call should only be allow on active versions
- fixing exceptions that are wrongly sent to sentry
This commit is contained in:
Thomas Trompette
2025-04-23 17:28:41 +02:00
committed by GitHub
parent a2d2db441f
commit 28a1354928
2 changed files with 27 additions and 4 deletions

View File

@ -46,10 +46,17 @@ export class WorkflowTriggerJob {
'workflow',
);
const workflow = await workflowRepository.findOneByOrFail({
const workflow = await workflowRepository.findOneBy({
id: data.workflowId,
});
if (!workflow) {
throw new WorkflowTriggerException(
'Workflow not found',
WorkflowTriggerExceptionCode.NOT_FOUND,
);
}
if (!workflow.lastPublishedVersionId) {
throw new WorkflowTriggerException(
'Workflow has no published version',
@ -62,10 +69,16 @@ export class WorkflowTriggerJob {
'workflowVersion',
);
const workflowVersion = await workflowVersionRepository.findOneByOrFail({
const workflowVersion = await workflowVersionRepository.findOneBy({
id: workflow.lastPublishedVersionId,
});
if (!workflowVersion) {
throw new WorkflowTriggerException(
'Workflow version not found',
WorkflowTriggerExceptionCode.NOT_FOUND,
);
}
if (workflowVersion.status !== WorkflowVersionStatus.ACTIVE) {
throw new WorkflowTriggerException(
'Workflow version is not active',