Skip to content

Fix Switch resume from serialized scheduled state#7444

Draft
sfmskywalker with Copilot wants to merge 2 commits into
release/3.7.0from
copilot/fix-switch-throws-on-resume
Draft

Fix Switch resume from serialized scheduled state#7444
sfmskywalker with Copilot wants to merge 2 commits into
release/3.7.0from
copilot/fix-switch-throws-on-resume

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

Purpose

Prevent Switch from throwing when a workflow resumes after ScheduledActivityIds has round-tripped through JSON serialization.


Scope

Select one primary concern:

  • Bug fix (behavior change)
  • Refactor (no behavior change)
  • Documentation update
  • Formatting / code cleanup
  • Dependency / build update
  • New feature

If this PR includes multiple unrelated concerns, please split it before requesting review.


Description

Problem

Switch stored scheduled child IDs as a HashSet<string>, but serialized workflow state restores that value as List<string>. The completion callback then read the value back as HashSet<string>, causing an InvalidCastException on resume.

Solution

  • Read ScheduledActivityIds as ICollection<string> so both the original HashSet<string> and restored List<string> are accepted.
  • Add a regression test covering child completion with list-restored scheduled activity IDs.
var scheduledActivityIds = context.TargetContext.GetProperty<ICollection<string>>("ScheduledActivityIds");

Verification

Steps:

  1. Run the targeted SwitchTests.
  2. Verify the restored-list regression test completes the Switch activity.
  3. Verify existing switch scheduling behavior remains unchanged.

Expected outcome:

Switch completes normally after resumed child completion when ScheduledActivityIds is restored as List<string>.


Screenshots / Recordings (if applicable)

N/A — no UI changes.


Commit Convention

We recommend using conventional commit prefixes:

  • fix: – Bug fixes (behavior change)
  • feat: – New features
  • refactor: – Code changes without behavior change
  • docs: – Documentation updates
  • chore: – Maintenance, tooling, or dependency updates
  • test: – Test additions or modifications

Clear commit messages make reviews easier and history more meaningful.


Checklist

  • The PR is focused on a single concern
  • Commit messages follow the recommended convention
  • Tests added or updated (if applicable)
  • Documentation updated (if applicable)
  • No unrelated cleanup included
  • All tests pass

Agent-Logs-Url: https://github.com/elsa-workflows/elsa-core/sessions/7fbc9229-29e2-4257-89d8-2890c764c8b1

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix switch throwing exception on resume from JSON-serialized state Fix Switch resume from serialized scheduled state May 12, 2026
Copilot AI requested a review from sfmskywalker May 12, 2026 14:29
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.

Switch throws on resume from JSON-serialized state

2 participants