elsa-workflows/elsa-core · critical · InvalidOperationException

BPMN process activity

Error message

BPMN process activity '{_process.Id}' has no process definition to execute.

What it means

BpmnScopeHost.BuildGraph requires the process activity to carry an actual BPMN process definition (_process.Process). When it is null — the activity exists but has no compiled definition attached — an InvalidOperationException is thrown stating the process activity has no definition to execute. This is an internal consistency guard before graph building.

Solutions

  1. Verify the workflow definition still exists and is published; re-import the BPMN document if needed.
  2. Rebuild/redeploy the workflow so the process activity is re-bound to its definition.
  3. Check the model loading path (interchange import → activity compilation) for a step that failed silently.
Defensive patterns

Strategy: try-catch

Validate before calling

if (processActivity.Process is null) throw new InvalidOperationException($"Process activity '{processActivity.Id}' is missing its definition; re-publish the workflow.");

Type guard

bool HasDefinition(BpmnProcessActivity p) => p?.Process is not null;

Try / catch

try { await host.ExecuteAsync(context); }
catch (InvalidOperationException ex) when (ex.Message.Contains("no process definition")) { log.LogError(ex, "Unbound BPMN process activity {Id}", ex.Message); /* re-import / republish definition */ }

Prevention

When it happens

Trigger: Executing a BPMN process activity whose Process definition property was never populated — e.g. the definition failed to load/compile, or the activity was constructed without its definition reference during model binding.

Common situations: Broken deployment where the definition was deleted or renamed after instances referenced it; serialization round-trips losing the definition link; custom activity construction bypassing the loader.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at src/modules/Elsa.Bpmn/Hosting/BpmnScopeHost.cs:379

            HasEnclosingScope: invocationCorrelation.Count > 0,
            LiveWork: memory.Work.ToLiveWork(),
            InvocationCorrelation: invocationCorrelation,
            Variables: new BpmnScopeVariables(_context),
            Capabilities: Capabilities);
    }

    /// <summary>
    /// The correlation of the work that started this scope. It belongs to the scope and is fixed for its lifetime;
    /// a completing unit of work's correlation is never written here, because the event-subprocess start hint is read
    /// from this same dictionary.
    /// </summary>
    private IReadOnlyDictionary<string, string> InvocationCorrelation =>
        BpmnScopeMemory.Read<Dictionary<string, string>>(_context, InvocationCorrelationPropertyKey) ?? NoCorrelation;

    private BpmnGraph BuildGraph()
    {
        var definition = _process.Process
                         ?? throw new InvalidOperationException($"BPMN process activity '{_process.Id}' has no process definition to execute.");

        // Every binding the definition declares, with the nested definition attached where the bound activity is
        // itself a BPMN scope. The graph validator reads that for an event subprocess body's start trigger.
        var boundWork = BpmnBoundWork.Derive(definition, bindingRef => (_process.FindWorkActivity(bindingRef) as BpmnProcess)?.Process);

        return BpmnGraph.Build(definition, boundWork, Capabilities);
    }
}

View on GitHub (pinned to fe9217bdfa)