elsa-workflows / elsa-workflows/elsa-core
V3 - Error with Activity Inputs because of collision in MemoryReference id
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
Hi,
I think I have detected what could be a critical issue in saving workflows after having modified the code of an activity and having incorporated new inputs.
To reproduce the bug i created this dummy activity initially with 2 Inputs:
```
[Activity("Test",
Category = "Test",
DisplayName = "Test inputs",
Description = "Reproduce the bug"
)]
public class TestInputActivity : Activity
{
[Input(
DisplayName = "Test1",
UIHint = InputUIHints.SingleLine,
SupportedSyntaxes = new[] { "JavaScript" }
)]
public Input Test1 { get; set; } = new(string.Empty);
//[Input(
// DisplayName = "Test1_5",
// UIHint = InputUIHints.SingleLine,
// SupportedSyntaxes = new[] { "JavaScript" }
//)]
//public Input Test1_5 { get; set; } = new(string.Empty);
[Input(
DisplayName = "Test2",
UIHint = InputUIHints.SingleLine,
SupportedSyntaxes = new[] { "JavaScript" }
)]
public Input Test2 { get; set; } = new(string.Empty);
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
context.SetResult(Test2.Get(context));
await context.CompleteActivityAsync();
}
}
```
Used in a workflow definition its works normally:

But now is when she goes crazy:
1. Add a third Input between Input 1 and Input 2
2. Change the output of the activity to Input 1_5
3. Run the server
4. Go to the test workflow definition
5. Execute
6. Surprise! The activity is setting as result the value of Input 2 instead of the new Input 1_5 between both and the value set to the input 1_5 is empty.

I check the export .json and there is a collision between the MemoryReference of the inputs

[test2.json](https://github.com/elsa-workflows/elsa-core/files/14916961/test2.json)
I think this can seriously endanger modifications to activities in production flows (it has happened to us in QA environments)
Contributor guide
Assessment
This issue has not been assessed yet.