elsa-workflows / elsa-workflows/elsa-core
WorkflowContextProvider not refreshed when context parameters are updated at runtime
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
I am using Elsa 3.5.1 and implementing a custom WorkflowContextProvider.
In Activity A, I dynamically set a workflow context parameter:
context.WorkflowExecutionContext.SetConversationSessionId("8:827076097151828");
In Activity B, I can successfully read it using:
var sessionId = context.WorkflowExecutionContext.GetConversationSessionId();
The session ID is correctly passed between activities.
The Problem:
Inside Activity B, I attempt to load the workflow context using
var session = context.ExpressionExecutionContext.GetConversationSession(); but it returns null.
The workflow context parameter is correctly set before Activity B runs.
code:
public class ConversationSessionContextProvider : WorkflowContextProvider
{
protected override async ValueTask LoadAsync(WorkflowExecutionContext context)
{
var sessionId = context.GetConversationSessionId();
return string.IsNullOrWhiteSpace(sessionId)
? null
: await conversationSessionStore.GetAsync(sessionId);
}
}
Activity A : context.WorkflowExecutionContext.SetConversationSessionId("session-id");
Activity B:
var sessionId = context.WorkflowExecutionContext.GetConversationSessionId(); // OK
var session = context.ExpressionExecutionContext.GetConversationSession(); // NULL
Extenjsions:
public static ConversationSession GetConversationSession(this ExpressionExecutionContext context)
{
return context.GetWorkflowContext();
}
Contributor guide
Assessment
This issue has not been assessed yet.