elsa-workflows/elsa-core · error · InvalidOperationException
Activity not found.
Error message
Activity not found.
What it means
An InvalidOperationException thrown when reading another activity's output by id or name and no matching activity can be found in the current workflow. The lookup (FindActivityByIdOrName) resolves within the workflow's activity tree; nothing matched.
Solutions
- Verify the activity ID or Name exactly matches an activity present in the current workflow (check the designer).
- Re-copy the activity's ID after the workflow was edited or the activity recreated.
- If the target is inside a composite, ensure the reference is resolvable from the current execution context.
- Prefer stable explicit Names over auto-generated IDs for cross-activity references.
Example fix
// before
await context.GetActivityOutputAsync("Activity_1abcOLD", "Result");
// after
await context.GetActivityOutputAsync("FetchOrder", "Result"); // Name set on the activity in the designer Defensive patterns
Strategy: validation
Validate before calling
// resolve and verify before reading output
var activity = context.FindActivityByIdOrName(activityIdOrName);
if (activity is null)
throw new ArgumentException($"Activity '{activityIdOrName}' does not exist in this workflow."); Try / catch
catch (InvalidOperationException ex) when (ex.Message == "Activity not found.")
{
logger.LogError("Referenced activity '{Ref}' missing; workflow may have been edited.", activityIdOrName);
} Prevention
- Give activities stable explicit Names used in references.
- Re-verify activity IDs after editing workflows in the designer.
- Avoid hard-copying auto-generated IDs between workflow versions.
When it happens
Trigger: Calling GetActivityOutput/GetActivityOutputAsync-style extension methods with an activityIdOrName that does not exist in the workflow, or referencing an activity scoped to a composite/parent workflow not visible from the current execution context.
Common situations: Copying an activity ID from an old workflow version; typo in activity Name; referencing an activity inside a composite workflow that is not part of the current workflow graph; activities renamed in the designer.
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
- Output conversion failed during result validation
- Output conversion failed during destination resolution
- Activity type not found
- Activity descriptor not found
- No input with name could be found
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/35cba16a301aa0ca.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Workflows.Core/Extensions/ExpressionExecutionContextExtensions.cs:462
var input = workflowExecutionContext.Input;
return input.TryGetValue(name, out var value) ? value : null;
}
/// <summary>
/// Returns the value of the specified output.
/// </summary>
/// <param name="activityIdOrName">The ID or name of the activity.</param>
/// <param name="outputName">The name of the output.</param>
/// <returns>The value of the specified output.</returns>
/// <exception cref="InvalidOperationException">Thrown when the activity is not found.</exception>
public object? GetOutput(string activityIdOrName, string? outputName)
{
var workflowExecutionContext = context.GetWorkflowExecutionContext();
var activityExecutionContext = context.GetActivityExecutionContext();
var activity = activityExecutionContext.FindActivityByIdOrName(activityIdOrName);
if (activity == null)
throw new InvalidOperationException("Activity not found.");
var outputRegister = workflowExecutionContext.GetActivityOutputRegister();
var outputRecordCandidates = outputRegister.FindMany(activity.Id, outputName);
var containerIds = activityExecutionContext.GetAncestors().Select(x => x.Id).ToList();
var filteredOutputRecordCandidates = outputRecordCandidates.Where(x => containerIds.Contains(x.ContainerId));
var outputRecord = filteredOutputRecordCandidates.FirstOrDefault();
return outputRecord?.Value;
}
/// <summary>
/// Returns all activity outputs.
/// </summary>
public async IAsyncEnumerable<ActivityOutputs> GetActivityOutputs()
{
if (!context.TryGetActivityExecutionContext(out var activityExecutionContext))
yield break;
var useActivityName = activityExecutionContext.WorkflowExecutionContext.Workflow.CreatedWithModernTooling();View on GitHub (pinned to fe9217bdfa)