elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.27k stars 1.15k forks source link

[BUG] WorkflowInput does not persist in Bookmark Callback #5303

Open defunky opened 5 months ago

defunky commented 5 months ago

Description

When assigning values in the WorkflowInputwithin ActivityExecutionContext within Execute methods either directly via activity or via starting workflow the WorkflowInputdictionary persists between each activity step. When an activity has a callback function via a Bookmark, accessing WorkflowInputwithin this callback is empty. The expected behaviour is to maintain the Workflow Inputs throughout the lifetime of the Workflow. I believe this might be because WorkflowInputcan be set in the TriggerOptionclass in the ResumeWorkflowand when it's not set, it will initalise an empty Dictonary instead.

Steps to Reproduce

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

Detailed Steps:

  1. Create two activities
  2. In first activity assign something to WorkflowInputwithin context inside of Execute method
  3. In the second activity assign additional element within WorkflowInputinside the Execute method
  4. You should have two elements when querying WorkflowInputin the second activity containing the elements you had specified
  5. In sceond activity create a bookmark with a callback
  6. Use IWorkflowRunTimeand resume the workflow without specify any additional options
  7. Access WorkflowInputwithin the callback method
  8. WorkflowInputis empty and the elements assign previous are lost

Reproduction Rate: Everytime

Expected Behavior

The WorkflowInputwithin the bookmark callback should persist all values defined previous in the current execution of the workflow

Actual Behavior

WorkflowInputis empty and has no values, as a result losing all WorkflowInput values previously assigned

Environment

glime-ai[bot] commented 5 months ago

Based on the provided context, it seems that you are experiencing an issue where the WorkflowInput dictionary is not persisting its values across different steps of the workflow, particularly after resuming from a bookmark. This behavior is unexpected as the WorkflowInput should maintain its state throughout the execution of the workflow.

This could potentially be a bug in the Elsa Workflow version you are using (3.1). The expected behavior is that the WorkflowInput should be accessible and should retain all the values that were previously set during the workflow execution, even after resuming from a bookmark.

To address this issue, you should:

  1. Ensure that you are using the latest version of Elsa Workflow, as this might be a bug that has been fixed in a newer release.
  2. Review the documentation to confirm that your implementation aligns with the expected usage patterns for WorkflowInput.
  3. Check the Elsa GitHub issues and discussions to see if this is a known issue and if there are any suggested workarounds or fixes.
  4. If the issue persists and is not addressed in the documentation or GitHub issues, consider reporting this behavior as a bug on the Elsa GitHub repository.

In the meantime, as a workaround, you might consider manually persisting the WorkflowInput values across bookmarks by using a custom persistence mechanism or by storing the values in a database or cache that can be accessed after resuming the workflow.

Please let me know if you need further assistance or if there are any specific details you would like to know regarding this issue.

This comment was generated by Glime.