{"record":{"id":"35cba16a301aa0ca","repo":"elsa-workflows/elsa-core","slug":"activity-not-found","errorCode":null,"errorMessage":"Activity not found.","messagePattern":"Activity not found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Core/Extensions/ExpressionExecutionContextExtensions.cs","lineNumber":462,"sourceCode":"            var input = workflowExecutionContext.Input;\n            return input.TryGetValue(name, out var value) ? value : null;\n        }\n\n        /// <summary>\n        /// Returns the value of the specified output.\n        /// </summary>\n        /// <param name=\"activityIdOrName\">The ID or name of the activity.</param>\n        /// <param name=\"outputName\">The name of the output.</param>\n        /// <returns>The value of the specified output.</returns>\n        /// <exception cref=\"InvalidOperationException\">Thrown when the activity is not found.</exception>\n        public object? GetOutput(string activityIdOrName, string? outputName)\n        {\n            var workflowExecutionContext = context.GetWorkflowExecutionContext();\n            var activityExecutionContext = context.GetActivityExecutionContext();\n            var activity = activityExecutionContext.FindActivityByIdOrName(activityIdOrName);\n\n            if (activity == null)\n                throw new InvalidOperationException(\"Activity not found.\");\n\n            var outputRegister = workflowExecutionContext.GetActivityOutputRegister();\n            var outputRecordCandidates = outputRegister.FindMany(activity.Id, outputName);\n            var containerIds = activityExecutionContext.GetAncestors().Select(x => x.Id).ToList();\n            var filteredOutputRecordCandidates = outputRecordCandidates.Where(x => containerIds.Contains(x.ContainerId));\n            var outputRecord = filteredOutputRecordCandidates.FirstOrDefault();\n            return outputRecord?.Value;\n        }\n\n        /// <summary>\n        /// Returns all activity outputs.\n        /// </summary>\n        public async IAsyncEnumerable<ActivityOutputs> GetActivityOutputs()\n        {\n            if (!context.TryGetActivityExecutionContext(out var activityExecutionContext))\n                yield break;\n\n            var useActivityName = activityExecutionContext.WorkflowExecutionContext.Workflow.CreatedWithModernTooling();","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Extensions/ExpressionExecutionContextExtensions.cs#L444-L480","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait context.GetActivityOutputAsync(\"Activity_1abcOLD\", \"Result\");\n\n// after\nawait context.GetActivityOutputAsync(\"FetchOrder\", \"Result\"); // Name set on the activity in the designer","handlingStrategy":"validation","validationCode":"// resolve and verify before reading output\nvar activity = context.FindActivityByIdOrName(activityIdOrName);\nif (activity is null)\n    throw new ArgumentException($\"Activity '{activityIdOrName}' does not exist in this workflow.\");","typeGuard":null,"tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message == \"Activity not found.\")\n{\n    logger.LogError(\"Referenced activity '{Ref}' missing; workflow may have been edited.\", activityIdOrName);\n}","preventionTips":["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."],"tags":["workflow","output","csharp"],"backgroundTag":"resource-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"}