{"record":{"id":"360956c52ff12a0d","repo":"elsa-workflows/elsa-core","slug":"activity-activity-id-is-not-reachable-from-the-flowchart","errorCode":null,"errorMessage":"Activity {activity.Id} is not reachable from the flowchart graph. Unable to schedule it's outbound activities.","messagePattern":"Activity (.+?) is not reachable from the flowchart graph\\. Unable to schedule it's outbound activities\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.Counters.cs","lineNumber":178,"sourceCode":"    /// </summary>\n    /// <param name=\"flowGraph\">The graph representation of the flowchart.</param>\n    /// <param name=\"flowScope\">Tracks activity and connection visits.</param>\n    /// <param name=\"flowchartContext\">The execution context of the flowchart.</param>\n    /// <param name=\"activity\">The current activity being processed.</param>\n    /// <param name=\"completedActivityContext\">The execution context of the completed activity (for call stack tracking).</param>\n    /// <param name=\"outcomes\">The outcomes that determine which connections were followed.</param>\n    /// <param name=\"completionCallback\">The callback to invoke upon activity completion.</param>\n    /// <param name=\"completedActivityExecutedByBackwardConnection\">Indicates if the completed activity\n    /// was executed due to a backward connection.</param>\n    /// <returns>True if at least one activity was scheduled; otherwise, false.</returns>\n    private static async ValueTask<bool> MaybeScheduleOutboundActivitiesAsync(FlowGraph flowGraph, FlowScope flowScope, ActivityExecutionContext flowchartContext, IActivity activity, ActivityExecutionContext? completedActivityContext, Outcomes outcomes, ActivityCompletionCallback completionCallback, bool completedActivityExecutedByBackwardConnection = false)\n    {\n        bool hasScheduledActivity = false;\n\n        // Check if the activity is dangling (i.e., it is not reachable from the flowchart graph)\n        if (flowGraph.IsDanglingActivity(activity))\n        {\n            throw new($\"Activity {activity.Id} is not reachable from the flowchart graph. Unable to schedule it's outbound activities.\");\n        }\n\n        // Register the activity as visited unless it was executed due to a backward connection\n        if (!completedActivityExecutedByBackwardConnection)\n        {\n            flowScope.RegisterActivityVisit(activity);\n        }\n\n        // Process each outbound connection from the current activity\n        foreach (var outboundConnection in flowGraph.GetOutboundConnections(activity))\n        {\n            var connectionFollowed = outcomes.Names.Contains(outboundConnection.Source.Port);\n            flowScope.RegisterConnectionVisit(outboundConnection, connectionFollowed);\n            var outboundActivity = outboundConnection.Target.Activity;\n\n            // Determine the scheduling strategy based on connection-type.\n            if (flowGraph.IsBackwardConnection(outboundConnection, out var backwardConnectionIsValid))\n                // Backward connections are scheduled differently","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.Counters.cs#L160-L196","documentation":"When an activity completes, the Flowchart tries to schedule its outbound connections' targets. If the completed activity is dangling — not reachable from the flowchart's start node in the flow graph — there is no valid graph path to follow and the engine refuses to schedule outbound activities, throwing InvalidOperationException. This guards against scheduling work that the graph model cannot account for.","triggerScenarios":"An activity completes whose node was scheduled outside the normal graph traversal (e.g. scheduled programmatically, via an event/trigger, or from a connection not part of the flow graph rooted at Start), and FlowGraph.IsDanglingActivity returns true during MaybeScheduleOutboundActivitiesAsync.","commonSituations":"Activities connected only to another dangling node; activities scheduled from custom code inside the flowchart without a connection; graphs modified at runtime (dynamic activities) after the flow graph was built; deleted/renamed start connections leaving orphan nodes.","solutions":["Connect every activity in the flowchart to the graph with a path from the Start activity.","If the activity is intentionally triggered externally, move it out of the Flowchart or use an event-based activity that the graph reaches.","Rebuild the designer connections so the activity is not orphaned (check for deleted inbound links).","Catch the exception in custom scheduling code and skip outbound scheduling for such activities."],"exampleFix":"// before: orphaned activity in designer\n// (WriteLine1 has no inbound connection from Start)\n// after: connect Start -> WriteLine1 -> End, or delete the unused WriteLine1 node","handlingStrategy":"validation","validationCode":"var graph = new FlowGraph(flowchart, activityVisitor, connectionTraverser);\nforeach (var node in flowchart.Activities)\n    if (graph.IsDanglingActivity(node.Activity))\n        throw new InvalidOperationException($\"Activity '{node.Activity.Id}' is not reachable from Start.\");","typeGuard":null,"tryCatchPattern":"try { await MaybeScheduleOutboundActivitiesAsync(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not reachable from the flowchart graph\"))\n{\n    logger.LogWarning(ex, \"Skipping outbound scheduling for unreachable activity.\");\n}","preventionTips":["Verify every node in the designer has a path from Start before publishing.","Avoid scheduling flowchart children from external code without graph connections.","Re-check flows after node deletion; dangling leftovers are the usual cause.","Run graph validation as part of workflow definition import."],"tags":["flowchart","graph-connectivity","workflow-engine","dangling-activity"],"backgroundTag":"invalid-state-transition","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}