elsa-workflows/elsa-core · error · NotSupportedException
Expression type is not supported as Expression
Error message
Expression type {exprNode.GetType().Name} is not supported as Expression What it means
CompileExpressionAsExpression converts expression nodes into Elsa Expression objects. Literal nodes, variable nodes, and explicit ElsaExpressionNode (language + code) are supported; any other node type triggers this NotSupportedException. It signals the DSL script used an expression shape that cannot be represented as a workflow Expression.
Solutions
- Rewrite the argument as an explicit Elsa expression with a language tag, e.g. `(js) a + b` or `${...}`
- Replace the computed expression with a literal or variable reference
- Move complex logic into the expression body rather than the DSL syntax
- Extend CompileExpressionAsExpression to support the missing node type if appropriate
Example fix
// before
SetVariable(value: count + 1)
// after
SetVariable(value: `${count + 1}`) Defensive patterns
Strategy: try-catch
Try / catch
try { expr = CompileExpressionAsExpression(node); }
catch (NotSupportedException ex) when (ex.Message.Contains("not supported as Expression"))
{
logger.LogError("Rewrite argument as (language) code or ${...}: {NodeType}", ex.Message);
throw;
} Prevention
- Always tag dynamic expressions with a language, e.g. (js) ... or ${...}
- Do not use raw binary/member/call nodes where declarative Expressions are expected
- Validate scripts against supported expression node types before deploy
When it happens
Trigger: Using a complex expression node (binary op, member chain, call) in a context where a declarative Expression is expected, instead of a literal, variable reference, or explicitly tagged expression like `(javascript) ...`.
Common situations: Writing inline computed expressions in activity properties; migrating scripts from another DSL syntax; parser producing node types the expression compiler does not cover.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Expression type is not supported
- Entry point label ' ' not found in flowchart
- No matching constructor found for activity type
- Multiple matching constructors found for activity type
- Unexpected non-optional, non-Input
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/52c47e3a66163c79.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs:478
}
throw new NotSupportedException($"Expression type {exprNode.GetType().Name} is not supported");
}
private Expression CompileExpressionAsExpression(ExpressionNode exprNode)
{
if (exprNode is LiteralNode literal)
{
return Expression.LiteralExpression(literal.Value);
}
if (exprNode is ElsaExpressionNode elsaExpr)
{
var language = elsaExpr.Language != null ? MapLanguageName(elsaExpr.Language) : _defaultExpressionLanguage;
return new(language, elsaExpr.Expression);
}
throw new NotSupportedException($"Expression type {exprNode.GetType().Name} is not supported as Expression");
}
[UnconditionalSuppressMessage("Trimming", "IL2060:Call to MakeGenericMethod can not be statically analyzed", Justification = "ElsaScript activity input types are discovered from runtime activity descriptors and must be bound dynamically.")]
private object CompileExpression(ExpressionNode exprNode, Type targetType)
{
// Check if targetType is already Input<T>
Type innerType;
if (targetType.IsGenericType && targetType.GetGenericTypeDefinition() == typeof(Input<>))
{
// Extract the T from Input<T>
innerType = targetType.GetGenericArguments()[0];
}
else
{
innerType = targetType;
}
// Use reflection to call CompileExpressionAsInput<T>View on GitHub (pinned to fe9217bdfa)