From 6ddcd71c26f75f0d792315b833bce7b34fc2ba14 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 20 Aug 2025 10:50:56 +0200 Subject: [PATCH] Exclude blacklisted types (`string`, `object`, `Array`, `DateTime`) from workflow variable registration logic. (#6857) --- .../Handlers/ConfigureEngineWithVariableTypes.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/Elsa.JavaScript/Handlers/ConfigureEngineWithVariableTypes.cs b/src/modules/Elsa.JavaScript/Handlers/ConfigureEngineWithVariableTypes.cs index b458522f0..dbbf0bbdb 100644 --- a/src/modules/Elsa.JavaScript/Handlers/ConfigureEngineWithVariableTypes.cs +++ b/src/modules/Elsa.JavaScript/Handlers/ConfigureEngineWithVariableTypes.cs @@ -11,12 +11,22 @@ namespace Elsa.JavaScript.Handlers; public class ConfigureEngineWithWorkflowVariableTypes(IOptions options) : INotificationHandler { + // 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. + ]; + /// 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();