DeleteWorkflowLabels ignores version-deleted notifications; store version-delete APIs unused
Problem
DeleteWorkflowLabels only cleans associations when an entire definition is deleted. Deleting one or many versions leaves WorkflowDefinitionLabel rows for those WorkflowDefinitionVersionIds orphaned.
The association store already exposes version-scoped delete APIs (and conformance covers them), but nothing in the Labels module subscribes to the version-deleted notifications the management layer already publishes.
Evidence (main / elsa-core)
Handler only wires definition-level notifications
src/modules/Elsa.Labels/Handlers/DeleteWorkflowLabels.cs
- Handles
WorkflowDefinitionDeleted→DeleteByWorkflowDefinitionIdAsync - Handles
WorkflowDefinitionsDeleted→DeleteByWorkflowDefinitionIdsAsync - Does not handle
WorkflowDefinitionVersionDeleted/WorkflowDefinitionVersionsDeleted
Management already publishes version deletes
src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionManager.cs
DeleteVersionAsync→WorkflowDefinitionVersionDeletedBulkDeleteByIdsAsync→WorkflowDefinitionVersionsDeleted
Dead / unused store surface (unless callers exist outside Labels)
IWorkflowDefinitionLabelStore:
DeleteByWorkflowDefinitionVersionIdAsyncDeleteByWorkflowDefinitionVersionIdsAsync
Implemented by Memory + EF (InMemoryWorkflowDefinitionLabelStore, EFCoreWorkflowDefinitionLabelStore) and exercised in LabelStoreConformanceTests, but not invoked from DeleteWorkflowLabels.
Why it matters
Labels are assigned per version (WorkflowDefinitionLabels.Update sets WorkflowDefinitionVersionId = workflowDefinition.Id). Version delete without cascade leaves stale association rows until the whole definition is removed — wrong for FindByLabelIds / filter providers and for subtractive store hygiene.
Proposed direction
- Extend
DeleteWorkflowLabelsto handleWorkflowDefinitionVersionDeleted/WorkflowDefinitionVersionsDeletedusing the existing version-delete store methods (mirror definition-level handlers). - Alternatively, if product intent is “labels always follow definition id only”, delete the unused version-delete APIs and stop storing per-version rows — but current Update endpoint + store contract say otherwise.
Out of scope / already tracked
- Labels List
TotalCountMemory vs EF → #8170 - Labels Get/Post/Update missing
Name→ #8189 - Shell FastEndpoints Labels → #8188
Light milestone note for Crew Lead: Soft Backlog / correctness; small handler wiring; not auto-Ready.
Source: elsa-workflows/elsa-core