Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 6, 2026

When rescheduling a completed activity inside a sub-process and then completing it, the flowchart throws: Activity {id} is not reachable from the flowchart graph. Unable to schedule it's outbound activities.

The flowchart receives completion callbacks for all descendant activities, but its connection graph only contains direct children. When an activity inside a sub-process completes, the flowchart attempts to verify it's not dangling by checking the graph, which fails since only the sub-process container itself is in the graph.

Changes

  • Flowchart.cs: Add IsDirectChild() helper to check if completedActivityContext.ParentActivityExecutionContext == flowchartContext
  • Flowchart.Counters.cs: Skip connection processing for non-direct children in ProcessChildCompletedAsync()
  • Flowchart.Tokens.cs: Skip token processing for non-direct children in OnChildCompletedTokenBasedLogicAsync(), extract ClearTokensAndCompleteFlowchartAsync() helper

When a non-direct child completes, the flowchart now only checks if it should complete rather than attempting to schedule outbound connections.

// Before: Would fail with dangling activity error
if (flowGraph.IsDanglingActivity(activity)) 
    throw new($"Activity {activity.Id} is not reachable...");

// After: Skip flowchart logic for activities managed by intermediate containers
if (!IsDirectChild(flowchartContext, completedActivityContext))
{
    await CompleteIfNoPendingWorkAsync(flowchartContext);
    return;
}

Applies to both counter-based and token-based execution modes.

Original prompt

This section details on the original issue you should resolve

<issue_title>Error occurs when completing a rescheduled step in a workflow which was re-scheduled after completion.</issue_title>
<issue_description>@sfmskywalker

Description

Error occurs when completing a rescheduled step in a workflow that was moved backward.

Issue Summary: When I reschedule a completed step to move the workflow backward and then try to complete that step again, an error is thrown.

Error Details: Activity 2c39c6367b2855a0 is not reachable from the flowchart graph. Unable to schedule it's outbound activities.

Steps to Reproduce

To help us identify the issue more quickly, please follow these guidelines:

  1. Detailed Steps:

    1. Create a workflow containing a Sub-Process
    2. Ensure the Sub-Process contains: Event, Join, and If activities (json to create workflow and sub-process is given below)
    3. Create a workflow instance using the following API call:
    curl --location 'https://localhost:5001/elsa/api/workflow-definitions/5a23244b1687d561/dispatch' \
    --header 'accept: application/json' \
    --header 'Authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwOi8vZWxzYS5hcGkiLCJpc3MiOiJodHRwOi8vZWxzYS5hcGkiLCJleHAiOjE3NTkzMzQ1OTYsImlhdCI6MTc1OTI0ODE5NiwibmFtZSI6ImFkbWluIiwicGVybWlzc2lvbnMiOiIqIiwicm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE3NTkyNDgxOTZ9.HSo1JQRs1akGdCs67QFHk-6nGjiab0l4hHvtfkhJs6Y' \
    --header 'Content-Type: application/json' \
    --data '{}'
    1. Complete steps in the sub-process using event triggers:
    curl --location 'https://localhost:5001/elsa/api/events/SP1-Step1/trigger' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwOi8vZWxzYS5hcGkiLCJpc3MiOiJodHRwOi8vZWxzYS5hcGkiLCJleHAiOjE3NTkzMzQ1OTYsImlhdCI6MTc1OTI0ODE5NiwibmFtZSI6ImFkbWluIiwicGVybWlzc2lvbnMiOiIqIiwicm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE3NTkyNDgxOTZ9.HSo1JQRs1akGdCs67QFHk-6nGjiab0l4hHvtfkhJs6Y' \
    --data '{
        "workflowInstanceId": "27e3969b3b556eba",
        "WorkflowExecutionMode": "Synchronous",
        "input": {
        }
    }'
    1. Move ahead in the workflow by completing subsequent steps
    2. When wanting to incomplete a particular step, perform rescheduling using the alterations API:
    curl --location 'https://localhost:5001/elsa/api/alterations/run' \
    --header 'Authorization: Bearer eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwOi8vZWxzYS5hcGkiLCJpc3MiOiJodHRwOi8vZWxzYS5hcGkiLCJleHAiOjE3NTkzMzQ1OTYsImlhdCI6MTc1OTI0ODE5NiwibmFtZSI6ImFkbWluIiwicGVybWlzc2lvbnMiOiIqIiwicm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE3NTkyNDgxOTZ9.HSo1JQRs1akGdCs67QFHk-6nGjiab0l4hHvtfkhJs6Y' \
    --header 'Content-Type: application/json' \
    --data '{
        "alterations": [
            {
                "type": "ScheduleActivity",
                "activityId": "2c39c6367b2855a0"
            }
        ],
        "workflowInstanceIds": [
            "27e3969b3b556eba"
        ]
    }'
    1. Attempt to complete the rescheduled step using the same event trigger API (shown in step 4)
    2. Error occurs during step completion
  2. Code Snippets:

    Main Workflow JSON that reproduces this issue:

    main-workflow.json

    Sub-Process SP-1 JSON (demonstrates the Event activities within sub-process):
    SP-1.json

    Sub-Process SP-2 JSON (demonstrates the Event activities within sub-process):
    SP-2.json

    Sub-Process SP-3 JSON (demonstrates the Event activities within sub-process):
    SP-3.json

    Sub-Process SP-4 JSON (demonstrates the Event activities within sub-process):
    SP-4.json

  3. Reproduction Rate: Every time when attempting to complete a rescheduled step

  4. Screenshots:

    Image Image Image
  5. Additional Configuration:

    • Workflow always contains Sub-Process
    • Sub-Process always contains Event, Join, and If activities
    • Issue specifically occurs with rescheduling/backward movement scenarios

...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


This change is Reviewable

Copilot AI changed the title [WIP] Fix error when completing rescheduled step in workflow Fix flowchart error when rescheduling activities inside sub-processes Jan 6, 2026
Copilot AI requested a review from sfmskywalker January 6, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error occurs when completing a rescheduled step in a workflow which was re-scheduled after completion.

2 participants