elsa-workflows/elsa-core · error · NotSupportedException

Expression type is not supported

Error message

Expression type {exprNode.GetType().Name} is not supported

What it means

In ElsaScriptCompiler.CompileExpressionAsInput, when an expression node is compiled as an Input<T> value and the node is neither a literal, variable, nor (via EvaluateConstantExpression) a supported array literal, the compiler throws NotSupportedException naming the node type. The DSL only knows how to statically evaluate a fixed set of expression node shapes; anything else cannot be turned into a constructor argument value.

Solutions

  1. Wrap the dynamic expression in an explicit Elsa expression, e.g. `${...}` or `(js) ...`, so it becomes an Expression instead of a constant-evaluated value
  2. Simplify the argument to a literal or variable reference the compiler can evaluate
  3. Check the supported node types in EvaluateConstantExpression and restructure the script accordingly
  4. If this is a valid construct, extend CompileExpressionAsInput/EvaluateConstantExpression to handle the node type

Example fix

// before
WriteLine(message: user.Name.ToUpper())
// after
WriteLine(message: `${user.Name.toUpperCase()}`)
Defensive patterns

Strategy: try-catch

Try / catch

try { activity = CompileActivityInvocation(node); }
catch (NotSupportedException ex) when (ex.Message.Contains("is not supported"))
{
    // fall back to explicit ${} expression syntax for this argument
    throw new ElsaScriptAuthoringException(ex.Message + " — use `${...}` for dynamic arguments", ex);
}

Prevention

When it happens

Trigger: Passing a complex expression (e.g. a function call, binary operation, or interpolated expression) as a positional/named constructor argument to an activity invocation, where the compiler tries to evaluate it as a constant Input<T> value.

Common situations: Authoring ElsaScript and using arithmetic or function-call expressions in activity arguments; upgrading the DSL and using node types newly produced by the parser but not yet handled by the compiler.

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


AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/97db89cddf963c4d. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs:462

            // If not found, treat as a literal
            return new(new Literal<T>(default!));
        }

        if (exprNode is ElsaExpressionNode elsaExpr)
        {
            var language = elsaExpr.Language != null ? MapLanguageName(elsaExpr.Language) : _defaultExpressionLanguage;
            var expression = new Expression(language, elsaExpr.Expression);
            return new(expression);
        }

        if (exprNode is ArrayLiteralNode arrayLiteral)
        {
            // For array literals, evaluate to a constant array if all elements are literals
            var elements = arrayLiteral.Elements.Select(EvaluateConstantExpression).ToArray();
            return new((T)(object)elements);
        }

        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");
    }

View on GitHub (pinned to fe9217bdfa)