{"record":{"id":"167e79889b330dbf","repo":"elsa-workflows/elsa-core","slug":"statement-type-statement-gettype-name-is-not-supported","errorCode":null,"errorMessage":"Statement type {statement.GetType().Name} is not supported","messagePattern":"Statement type (.+?) is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs","lineNumber":153,"sourceCode":"            return defaultValue;\n        }\n    }\n\n    private async Task<IActivity?> CompileStatementAsync(StatementNode statement, CancellationToken cancellationToken = default)\n    {\n        return statement switch\n        {\n            VariableDeclarationNode varDecl => CompileVariableDeclaration(varDecl),\n            ActivityInvocationNode actInv => await CompileActivityInvocationAsync(actInv, cancellationToken),\n            BlockNode block => await CompileBlockAsync(block, cancellationToken),\n            IfNode ifNode => await CompileIfAsync(ifNode, cancellationToken),\n            ForEachNode forEach => await CompileForEachAsync(forEach, cancellationToken),\n            ForNode forNode => await CompileForAsync(forNode, cancellationToken),\n            WhileNode whileNode => await CompileWhileAsync(whileNode, cancellationToken),\n            SwitchNode switchNode => await CompileSwitchAsync(switchNode, cancellationToken),\n            FlowchartNode flowchart => await CompileFlowchartAsync(flowchart, cancellationToken),\n            ListenNode listen => await CompileListenAsync(listen, cancellationToken),\n            _ => throw new NotSupportedException($\"Statement type {statement.GetType().Name} is not supported\")\n        };\n    }\n\n    private IActivity? CompileVariableDeclaration(VariableDeclarationNode varDecl)\n    {\n        // Create and register the variable\n        var initialValue = varDecl.Value != null ? EvaluateConstantExpression(varDecl.Value) : null;\n        var variable = new Variable(varDecl.Name, initialValue);\n        _variables[varDecl.Name] = variable;\n\n        // Variable declarations don't produce activities themselves\n        return null;\n    }\n\n    private async Task<IActivity> CompileActivityInvocationAsync(ActivityInvocationNode actInv, CancellationToken cancellationToken = default)\n    {\n        // Try to find the activity type by name - try several strategies\n        var activityDescriptor = await activityRegistryLookupService.FindAsync(actInv.ActivityName);","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Dsl.ElsaScript/Compiler/ElsaScriptCompiler.cs#L135-L171","documentation":"ElsaScriptCompiler.CompileStatementAsync pattern-matches the AST statement against all supported node types (activity, for-each, for, while, switch, flowchart, listen, etc.); if a statement node falls through the switch, it throws NotSupportedException naming the node type. It means the script contains a construct the compiler does not know how to compile.","triggerScenarios":"Compiling an ElsaScript whose AST contains a statement node type absent from the compiler's switch — typically after adding a new parser node type without adding a CompileXxx case, or using an unsupported statement in the script.","commonSituations":"A DSL language/version mismatch where the parser produces nodes the compiler predates, custom forked nodes, or using a newly documented statement with an older Elsa.Dsl.ElsaScript package.","solutions":["Upgrade Elsa.Dsl.ElsaScript to a version whose compiler supports the statement type reported in the message.","Rewrite the script using supported statements (activity calls, var, if, for, foreach, while, switch, flowchart, listen).","If you own the parser, add the missing case in CompileStatementAsync dispatching to a new Compile method.","Catch NotSupportedException during compilation and surface the unsupported statement to the script author."],"exampleFix":"// before\nswitch (statement) { ... } // no case for RepeatNode\n// after (library-side)\nRepeatNode repeatNode => await CompileRepeatAsync(repeatNode, cancellationToken),\n_ => throw new NotSupportedException($\"Statement type {statement.GetType().Name} is not supported\");","handlingStrategy":"try-catch","validationCode":"const supported = ['activity','if','foreach','for','while','switch','flowchart','listen']; if (!supported.includes(ast.node.type)) reportUnsupported(ast.node.type);","typeGuard":"function isSupportedStatement(node) { return node && supportedStatementTypes.has(node.type); }","tryCatchPattern":"try { result = await compiler.CompileAsync(script); } catch (NotSupportedException ex) { editor.showError('Unsupported statement: ' + ex.Message); }","preventionTips":["Keep Elsa.Dsl.ElsaScript parser and compiler packages on the same version.","Restrict script authoring UI to supported statement constructs.","Pin package versions so a new parser node cannot reach an older compiler.","Add compiler tests for every statement type you allow in scripts."],"tags":["dsl","compiler","not-supported"],"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"}