{"record":{"id":"52c47e3a66163c79","repo":"elsa-workflows/elsa-core","slug":"expression-type-exprnode-gettype-name-is-not-supported-as","errorCode":null,"errorMessage":"Expression type {exprNode.GetType().Name} is not supported as Expression","messagePattern":"Expression type (.+?) is not supported as Expression","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs","lineNumber":478,"sourceCode":"        }\n\n        throw new NotSupportedException($\"Expression type {exprNode.GetType().Name} is not supported\");\n    }\n\n    private Expression CompileExpressionAsExpression(ExpressionNode exprNode)\n    {\n        if (exprNode is LiteralNode literal)\n        {\n            return Expression.LiteralExpression(literal.Value);\n        }\n\n        if (exprNode is ElsaExpressionNode elsaExpr)\n        {\n            var language = elsaExpr.Language != null ? MapLanguageName(elsaExpr.Language) : _defaultExpressionLanguage;\n            return new(language, elsaExpr.Expression);\n        }\n\n        throw new NotSupportedException($\"Expression type {exprNode.GetType().Name} is not supported as Expression\");\n    }\n\n    [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.\")]\n    private object CompileExpression(ExpressionNode exprNode, Type targetType)\n    {\n        // Check if targetType is already Input<T>\n        Type innerType;\n        if (targetType.IsGenericType && targetType.GetGenericTypeDefinition() == typeof(Input<>))\n        {\n            // Extract the T from Input<T>\n            innerType = targetType.GetGenericArguments()[0];\n        }\n        else\n        {\n            innerType = targetType;\n        }\n\n        // Use reflection to call CompileExpressionAsInput<T>","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs#L460-L496","documentation":"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.","triggerScenarios":"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) ...`.","commonSituations":"Writing inline computed expressions in activity properties; migrating scripts from another DSL syntax; parser producing node types the expression compiler does not cover.","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"],"exampleFix":"// before\nSetVariable(value: count + 1)\n// after\nSetVariable(value: `${count + 1}`)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { expr = CompileExpressionAsExpression(node); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"not supported as Expression\"))\n{\n    logger.LogError(\"Rewrite argument as (language) code or ${...}: {NodeType}\", ex.Message);\n    throw;\n}","preventionTips":["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"],"tags":["elsascript","compiler","expression","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}