The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Improve logs in workflow trigger (#12215)
Thomas Trompette4ac47c2a1ba0
diff --git a/packages/twenty-server/src/engine/core-modules/workflow/controllers/workflow-trigger.controller.ts b/packages/twenty-server/src/engine/core-modules/workflow/controllers/workflow-trigger.controller.tsindex 34fb47938dc..a38859e1c76 100644--- a/packages/twenty-server/src/engine/core-modules/workflow/controllers/workflow-trigger.controller.ts+++ b/packages/twenty-server/src/engine/core-modules/workflow/controllers/workflow-trigger.controller.ts@@ -28,23 +28,33 @@ export class WorkflowTriggerController {@Post('workflows/:workspaceId/:workflowId')async runWorkflowByPostRequest(+ @Param('workspaceId') workspaceId: string,@Param('workflowId') workflowId: string,@Req() request: Request,) {- return await this.runWorkflow({ workflowId, payload: request.body || {} });+ return await this.runWorkflow({+ workflowId,+ payload: request.body || {},+ workspaceId,+ });}@Get('workflows/:workspaceId/:workflowId')- async runWorkflowByGetRequest(@Param('workflowId') workflowId: string) {- return await this.runWorkflow({ workflowId });+ async runWorkflowByGetRequest(+ @Param('workspaceId') workspaceId: string,+ @Param('workflowId') workflowId: string,+ ) {+ return await this.runWorkflow({ workflowId, workspaceId });}private async runWorkflow({workflowId,payload,+ workspaceId,}: {workflowId: string;payload?: object;+ workspaceId: string;}) {const workflowRepository =await this.twentyORMManager.getRepository<WorkflowWorkspaceEntity>(@@ -57,7 +67,7 @@ export class WorkflowTriggerController {if (!isDefined(workflow)) {throw new WorkflowTriggerException(- 'Workflow not found',+ `[Webhook trigger] Workflow ${workflowId} not found in workspace ${workspaceId}`,WorkflowTriggerExceptionCode.NOT_FOUND,);}@@ -67,7 +77,7 @@ export class WorkflowTriggerController {workflow.lastPublishedVersionId === '') {throw new WorkflowTriggerException(- 'Workflow has not been activated',+ `[Webhook trigger] Workflow ${workflowId} has not been activated in workspace ${workspaceId}`,WorkflowTriggerExceptionCode.INVALID_WORKFLOW_STATUS,);}@@ -82,21 +92,21 @@ export class WorkflowTriggerController {if (!isDefined(workflowVersion)) {throw new WorkflowTriggerException(- 'Workflow version not found',+ `[Webhook trigger] No workflow version activated for workflow ${workflowId} in workspace ${workspaceId}`,WorkflowTriggerExceptionCode.INVALID_WORKFLOW_VERSION,);}if (workflowVersion.trigger?.type !== WorkflowTriggerType.WEBHOOK) {throw new WorkflowTriggerException(- 'Workflow does not have a Webhook trigger',+ `[Webhook trigger] Workflow ${workflowId} does not have a Webhook trigger in workspace ${workspaceId}`,WorkflowTriggerExceptionCode.INVALID_WORKFLOW_TRIGGER,);}if (workflowVersion.status !== WorkflowVersionStatus.ACTIVE) {throw new WorkflowTriggerException(- 'Workflow version is not active',+ `[Webhook trigger] Workflow version ${workflowVersion.id} is not active in workspace ${workspaceId}`,WorkflowTriggerExceptionCode.INVALID_WORKFLOW_STATUS,);}diff --git a/packages/twenty-server/src/modules/workflow/workflow-trigger/jobs/workflow-trigger.job.ts b/packages/twenty-server/src/modules/workflow/workflow-trigger/jobs/workflow-trigger.job.tsindex cda96fd05b3..6d24cd0d3d2 100644--- a/packages/twenty-server/src/modules/workflow/workflow-trigger/jobs/workflow-trigger.job.ts+++ b/packages/twenty-server/src/modules/workflow/workflow-trigger/jobs/workflow-trigger.job.ts@@ -52,14 +52,14 @@ export class WorkflowTriggerJob {if (!workflow) {throw new WorkflowTriggerException(- 'Workflow not found',+ `Workflow ${data.workflowId} not found in workspace ${data.workspaceId}`,WorkflowTriggerExceptionCode.NOT_FOUND,);}if (!workflow.lastPublishedVersionId) {throw new WorkflowTriggerException(- 'Workflow has no published version',+ `Workflow ${data.workflowId} has no published version in workspace ${data.workspaceId}`,WorkflowTriggerExceptionCode.INTERNAL_ERROR,);}@@ -75,13 +75,13 @@ export class WorkflowTriggerJob {if (!workflowVersion) {throw new WorkflowTriggerException(- 'Workflow version not found',+ `Workflow version ${workflow.lastPublishedVersionId} not found in workspace ${data.workspaceId}`,WorkflowTriggerExceptionCode.NOT_FOUND,);}if (workflowVersion.status !== WorkflowVersionStatus.ACTIVE) {throw new WorkflowTriggerException(- 'Workflow version is not active',+ `Workflow version ${workflowVersion.id} is not active in workspace ${data.workspaceId}`,WorkflowTriggerExceptionCode.INTERNAL_ERROR,);}