Skip to content

Added logic to search for workflow-as-activities based on DefinitionId (not only versionId)#7149

Merged
sfmskywalker merged 13 commits into
develop/3.6.0from
develop/3.6.0-bugfix-activityserialization
Dec 17, 2025
Merged

Added logic to search for workflow-as-activities based on DefinitionId (not only versionId)#7149
sfmskywalker merged 13 commits into
develop/3.6.0from
develop/3.6.0-bugfix-activityserialization

Conversation

@j03y-nxxbz

@j03y-nxxbz j03y-nxxbz commented Dec 17, 2025

Copy link
Copy Markdown
Contributor
  1. Fixed problem: (re-)added logic to search for workflow-as-activities based on DefinitionId (not only versionId)

  2. Added tests for Deserialization so this logic won't disappear "unnoticed" in the future.


This change is Reviewable

1. Fixed problem: (re-)added logic to search for workflow-as-activities based on DefinitionId (not only versionId)

2. Added tests for Deserialiazation so this logic cannot disappear "unnoticed" in the future.
@j03y-nxxbz

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree [company="Nexxbiz"]

@j03y-nxxbz

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree company="Nexxbiz"

@j03y-nxxbz j03y-nxxbz changed the title Inital commit: Added logic to search for workflow-as-activities based on DefinitionId (not only versionId) Dec 17, 2025
joey-orbyss and others added 4 commits December 17, 2025 15:59
workflowDefinitionId is also used in other activities. Therefore, we must make sure to only search by workflowDefinitionId when the value is a string (e.g. when workflow used as activity, the value will always be a constant string, because the workflowDefinitionId cannot be resolved using expressions)
1) First try to find the activity by type name
2) Even if a descriptor is found by its type name, there might be multiple versions of a workflow-as-activity, hence; if the workflowDefinitionVersionId is specified, then this can override the initially found activity descriptor by type name.
3) Lastly, only when no activity descriptor is found by type name AND the activity JSON contains the property "workflowDeftinitionId", then we can search by workflowDefinitionId
@sfmskywalker sfmskywalker requested a review from Copilot December 17, 2025 18:45
Comment thread src/modules/Elsa.Workflows.Core/Serialization/Converters/ActivityJsonConverter.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores and enhances the logic for deserializing workflow-as-activities based on WorkflowDefinitionId (not only WorkflowDefinitionVersionId), and adds comprehensive unit tests to prevent this functionality from being lost in future refactorings. The changes also include updates to the MySQL EF Core project configuration to exclude .NET 10.0 support due to Pomelo driver limitations, and package version updates for resilience-related libraries.

Key Changes

  • Refactored activity deserialization logic to search by WorkflowDefinitionId when WorkflowDefinitionVersionId is not available and no well-known activity type is found
  • Added comprehensive unit tests covering various deserialization scenarios for activities and workflow-as-activities
  • Limited MySQL EF Core provider to .NET 8/9 due to Pomelo compatibility constraints

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
src/modules/Elsa.Workflows.Core/Serialization/Converters/ActivityJsonConverter.cs Refactored GetActivityDetails method to handle WorkflowDefinitionId-based lookup; extracted FindActivityDescriptorByCustomProperty helper method; reordered logic to check well-known activities before workflow-as-activities
test/unit/Elsa.Workflows.Core.UnitTests/Serialization/Converters/ActivityJsonConverterTests.cs New comprehensive test file with 6 test cases covering deserialization scenarios for known/unknown activities, workflow-as-activities with DefinitionId, VersionId, and type name only
src/modules/Elsa.Persistence.EFCore.MySql/Elsa.Persistence.EFCore.MySql.csproj Added TargetFrameworks property to exclude net10.0 due to Pomelo EF Core MySQL provider limitation; minor formatting changes to PackageReference elements
Directory.Packages.props Updated Microsoft.Extensions.Http.Resilience and Microsoft.Extensions.Resilience versions from 9.0.11 to 9.10.0 for .NET 8/9 target frameworks

Comment thread src/modules/Elsa.Workflows.Core/Serialization/Converters/ActivityJsonConverter.cs Outdated
Comment thread src/modules/Elsa.Workflows.Core/Serialization/Converters/ActivityJsonConverter.cs Outdated
sfmskywalker and others added 5 commits December 17, 2025 20:05
Ensures the custom property lookup path is tested by mocking type name lookups to return null when searching for ActivityDescriptors.
Corrects the assignment logic for `activityDescriptor` and ensures `activityTypeVersion` uses the overridden descriptor's version when a custom property match is found.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Adjust null-check handling for `activityDescriptor` overrides.
- Improve comment clarity and consolidate lambda expressions.
- Remove unnecessary whitespace.
- Introduce `BlobExtensions` for extracting blob file extensions.
- Add `SupportsExtension` to `IBlobWorkflowFormatHandler` to filter handlers by supported extensions.
- Deleted `flowchart-test.elsa` and `multi-workflow-example.elsa`.
- Removed corresponding references from the project file.
@sfmskywalker sfmskywalker merged commit 48b574a into develop/3.6.0 Dec 17, 2025
7 of 8 checks passed
@sfmskywalker sfmskywalker deleted the develop/3.6.0-bugfix-activityserialization branch December 17, 2025 22:23
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.

4 participants