Exclude blacklisted types (string, object, Array, DateTime) from workflow variable registration logic. (#6857)

This commit is contained in:
Sipke Schoorstra 2025-08-20 10:50:56 +02:00 committed by GitHub
parent d72c4974d2
commit 6ddcd71c26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,12 +11,22 @@ namespace Elsa.JavaScript.Handlers;
public class ConfigureEngineWithWorkflowVariableTypes(IOptions<ManagementOptions> options)
: INotificationHandler<EvaluatingJavaScript>
{
// Blacklist of types to exclude from registration.
private static readonly Type[] BlacklistedTypes =
[
typeof(string),
typeof(object),
typeof(Array),
typeof(DateTime)
// Add more types if needed.
];
/// <inheritdoc />
public Task HandleAsync(EvaluatingJavaScript notification, CancellationToken cancellationToken)
{
var engine = notification.Engine;
var variableTypes = options.Value.VariableDescriptors
.Where(x => x.Type is { ContainsGenericParameters: false} && x.Type != typeof(object))
.Where(x => x.Type is { ContainsGenericParameters: false } && !BlacklistedTypes.Contains(x.Type) && !x.Type.IsPrimitive)
.Select(x => x.Type)
.ToArray();