From dc2184fba413e9d18061a172d7f5cc71f61857d2 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 5 Jun 2024 18:07:48 +0200 Subject: [PATCH] Add warning for ID mismatch in workflow definitions Added a check and corresponding log warning in the 'DefaultWorkflowDefinitionStorePopulator' class for cases where an imported workflow definition has a different ID than the existing one in the store. This will help in identifying ID discrepancies that may impact workflow execution or management. Future updates may include storing these discrepancies for troubleshooting purposes. --- .../DefaultWorkflowDefinitionStorePopulator.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs b/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs index 03b89dc28..aa0208a7b 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/DefaultWorkflowDefinitionStorePopulator.cs @@ -129,7 +129,17 @@ public class DefaultWorkflowDefinitionStorePopulator : IWorkflowDefinitionStoreP var workflowDefinitionsToSave = new HashSet(); if (existingDefinitionVersion != null) + { workflowDefinitionsToSave.Add(existingDefinitionVersion); + + if(existingDefinitionVersion.Id != workflow.Identity.Id) + { + // It's possible that the imported workflow definition has a different ID than the existing one in the store. + // In a future update, we might store this discrepancy in a "troubleshooting" table and provide tooling for managing these, and other, discrepancies. + // See https://github.com/elsa-workflows/elsa-core/issues/5540 + _logger.LogWarning("Workflow with ID {WorkflowId} already exists with a different ID {ExistingWorkflowId}", workflow.Identity.Id, existingDefinitionVersion.Id); + } + } await UpdateIsLatest(); await UpdateIsPublished();