elsa-workflows/elsa-core · error · Exception

No published version of workflow definition with ID

Error message

No published version of workflow definition with ID {workflowDefinitionId} found.

What it means

Thrown by the DispatchWorkflow activity (DispatchChildWorkflowAsync) when IWorkflowDefinitionService.FindWorkflowGraphAsync returns null for the requested workflow definition ID with VersionOptions.Published. It means no currently published version of the referenced definition exists, so the child workflow cannot be dispatched. Elsa resolves only published versions by default; drafts or superseded versions do not qualify.

Solutions

  1. Publish the target workflow definition (Studio publish action or IWorkflowDefinitionPublisher.PublishAsync) so a version with VersionOptions.Published exists.
  2. Verify the WorkflowDefinitionId input value matches an existing definition ID (check the workflow registry / definition store; watch for typos or IDs from another environment).
  3. If dispatching by definition name/version is intended, resolve the correct published definition ID first via IWorkflowDefinitionManager or the definitions API.
  4. Check version history: if the published version was superseded or retracted, publish a new version before running the parent workflow.

Example fix

// before: ID from a draft workflow, never published
var dispatch = new DispatchWorkflow { WorkflowDefinitionId = new("my-draft-workflow-id") };

// after: publish first, then reference the published definition
await workflowDefinitionPublisher.PublishAsync(draftDefinition);
var dispatch = new DispatchWorkflow { WorkflowDefinitionId = new(publishedDefinition.Id) };
Defensive patterns

Strategy: validation

Validate before calling

var graph = await workflowDefinitionService.FindWorkflowGraphAsync(workflowDefinitionId, VersionOptions.Published, ct);
if (graph is null)
    throw new InvalidOperationException($"Workflow definition '{workflowDefinitionId}' has no published version. Publish it before dispatching.");

Prevention

When it happens

Trigger: Executing a DispatchWorkflow activity whose WorkflowDefinitionId input points to a definition ID that has no published version at execution time (e.g. only a draft exists, the published version was retracted, or the ID is mistyped/points to a deleted definition).

Common situations: Referencing a workflow by ID copied from a draft or from JSON before publication; retracting or deleting the target workflow while a parent that dispatches it is still running; building the workflow programmatically and forgetting to publish via IWorkflowDefinitionPublisher; environment drift where the target workflow exists in one environment but was never published in another.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/b67aa86475965e0b. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Workflows.Runtime/Activities/DispatchWorkflow.cs:108

                IncludeActivityInstanceId = false
            };
            context.CreateBookmark(bookmarkOptions);
        }
        else
        {
            // Otherwise, we can complete immediately.
            await context.CompleteActivityAsync();
        }
    }

    private async ValueTask<string> DispatchChildWorkflowAsync(ActivityExecutionContext context, bool waitForCompletion)
    {
        var workflowDefinitionId = WorkflowDefinitionId.Get(context);
        var workflowDefinitionService = context.GetRequiredService<IWorkflowDefinitionService>();
        var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(workflowDefinitionId, VersionOptions.Published, context.CancellationToken);

        if (workflowGraph == null)
            throw new($"No published version of workflow definition with ID {workflowDefinitionId} found.");

        var input = Input.GetOrDefault(context) ?? new Dictionary<string, object>();
        var channelName = ChannelName.GetOrDefault(context);
        var startNewTrace = StartNewTrace.GetOrDefault(context);
        var parentInstanceId = context.WorkflowExecutionContext.Id;
        var properties = new Dictionary<string, object>
        {
            ["ParentInstanceId"] = parentInstanceId,
        };

        // If we need to wait for the child workflow to complete, set the property. This will be used by the ResumeDispatchWorkflowActivity handler.
        if (waitForCompletion) properties["WaitForCompletion"] = true;
        if (startNewTrace) properties["StartNewTrace"] = true;
        
        input["ParentInstanceId"] = parentInstanceId;

        var correlationId = CorrelationId.GetOrDefault(context);
        var workflowDispatcher = context.GetRequiredService<IWorkflowDispatcher>();

View on GitHub (pinned to fe9217bdfa)