elsa-workflows / elsa-workflows/elsa-core

V3 - Error with Activity Inputs because of collision in MemoryReference id

Open
#5,206 2 comments 0 reactions 0 assignees View on GitHub
bug elsa 3 triaged
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:
![Captura de pantalla 2024-04-09 a las 11 39 32](https://github.com/elsa-workflows/elsa-core/assets/34290325/8d40050b-9d12-4a79-8289-3ceff1fc85db)

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.

![Captura de pantalla 2024-04-09 a las 11 47 00](https://github.com/elsa-workflows/elsa-core/assets/34290325/70224956-7472-4fe1-8ac6-82d76b3e4f15)

I check the export .json and there is a collision between the MemoryReference of the inputs
![Captura de pantalla 2024-04-09 a las 11 53 21](https://github.com/elsa-workflows/elsa-core/assets/34290325/33f2f362-9141-41bf-becf-761f4275037f)

[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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.