{"record":{"id":"c96119e6f89f4ae1","repo":"elsa-workflows/elsa-core","slug":"activity-type-not-found-workflowexecutioncontext","errorCode":null,"errorMessage":"Activity type not found","messagePattern":"Activity type not found","errorType":"exception","errorClass":"ActivityNotFoundException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs","lineNumber":583,"sourceCode":"            throw new($\"Cannot transition from {SubStatus} to {subStatus}\");\n\n        SubStatus = subStatus;\n        UpdatedAt = SystemClock.UtcNow;\n\n        if (Status == WorkflowStatus.Finished)\n            FinishedAt = UpdatedAt;\n\n        if (Status == WorkflowStatus.Finished || SubStatus == WorkflowSubStatus.Suspended)\n        {\n            foreach (var registration in _cancellationRegistrations)\n                registration.Dispose();\n        }\n    }\n\n    /// Creates a new <see cref=\"ActivityExecutionContext\"/> for the specified activity.\n    public async Task<ActivityExecutionContext> CreateActivityExecutionContextAsync(IActivity activity, ActivityInvocationOptions? options = null)\n    {\n        var activityDescriptor = await ActivityRegistryLookup.FindAsync(activity) ?? throw new ActivityNotFoundException(activity.Type);\n        var tag = options?.Tag;\n        var parentContext = options?.Owner;\n        var now = SystemClock.UtcNow;\n        var id = IdentityGenerator.GenerateId();\n        var activityExecutionContext = new ActivityExecutionContext(id, this, parentContext, activity, activityDescriptor, now, tag, SystemClock, CancellationToken);\n        var variablesToDeclare = options?.Variables ?? [];\n        var variableContainer = new[]\n        {\n            activityExecutionContext.ActivityNode\n        }.Concat(activityExecutionContext.ActivityNode.Ancestors()).FirstOrDefault(x => x.Activity is IVariableContainer)?.Activity as IVariableContainer;\n        activityExecutionContext.ExpressionExecutionContext.TransientProperties[ExpressionExecutionContextExtensions.ActivityExecutionContextKey] = activityExecutionContext;\n\n        if (variableContainer != null)\n        {\n            foreach (var variable in variablesToDeclare)\n            {\n                // Declare a dynamic variable on the activity execution context.\n                activityExecutionContext.DynamicVariables.RemoveWhere(x => x.Name == variable.Name);","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Contexts/WorkflowExecutionContext.cs#L565-L601","documentation":"An ActivityNotFoundException raised while creating an ActivityExecutionContext because ActivityRegistryLookup.FindAsync could not resolve the activity's Type to a registered activity descriptor. Every activity instance must map to a descriptor registered in the ActivityRegistry.","triggerScenarios":"Calling WorkflowExecutionContext.CreateActivityExecutionContextAsync with an IActivity whose Type string does not match any registered activity type - typically custom activities not registered via a feature/module, or activities from assemblies not loaded.","commonSituations":"Custom activity class added to a workflow but its module/feature was not installed on the host; typo or renamed activity type; deserialized workflow JSON referencing an activity type from a package no longer referenced; missing AddActivity/InstallFeatures registration.","solutions":["Register the activity type with the workflow runtime (implement IActivityProvider / feature module that installs the descriptor).","Verify the activity's Type string matches the registered descriptor's Type exactly (case-sensitive).","Ensure the NuGet package / assembly containing the activity is referenced and its feature is installed.","Check for type renames after upgrades and update persisted workflow definitions accordingly."],"exampleFix":"// before\n// Custom MyActivity used in workflow but never registered -> ActivityNotFoundException\n\n// after\npublic class MyActivityFeature : IFeature\n{\n    public void Apply() => Module.AddActivity<MyActivity>();\n}\n// or via services.AddActivity<MyActivity>(); in host setup","handlingStrategy":"validation","validationCode":"// at host startup, assert all workflow activity types are registered\nvar lookup = services.GetRequiredService<IActivityRegistryLookupService>();\nforeach (var type in usedActivityTypes)\n    if (await lookup.FindAsync(type) is null)\n        throw new InvalidOperationException($\"Activity type '{type}' is not registered. Install its feature.\");","typeGuard":null,"tryCatchPattern":"// catch Elsa.Workflows.Core.Exceptions.ActivityNotFoundException\ncatch (ActivityNotFoundException ex)\n{\n    logger.LogError(ex, \"Unregistered activity type {Type}; install the owning module/feature.\", ex.ActivityType);\n}","preventionTips":["Install every module/feature whose activities your workflows use.","Add a startup smoke test that loads all workflow definitions.","After package upgrades, verify activity Type strings in persisted workflows still resolve."],"tags":["workflow","activity-registry","csharp"],"backgroundTag":"entity-not-found","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}