elsa-workflows / elsa-workflows/elsa-core

WorkflowContextProvider not refreshed when context parameters are updated at runtime

Open
#7,139 0 comments 0 reactions 0 assignees View on GitHub
triaged
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

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.