{"record":{"id":"39febc6975d0c960","repo":"OrchardCMS/OrchardCore","slug":"the-syntax-syntax-isn-t-supported-for-whilelooptask","errorCode":null,"errorMessage":"The syntax {Syntax} isn't supported for WhileLoopTask.","messagePattern":"The syntax (.+?) isn't supported for WhileLoopTask\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Workflows/Activities/WhileLoopTask.cs","lineNumber":58,"sourceCode":"        set => SetProperty(value);\n    }\n\n    public WorkflowScriptSyntax Syntax\n    {\n        get => GetProperty(() => WorkflowScriptSyntax.JavaScript);\n        set => SetProperty(value);\n    }\n\n    public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContext workflowContext, ActivityContext activityContext)\n        => Outcome(S[\"Iterate\"], S[\"Done\"]);\n\n    public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)\n    {\n        var loop = Syntax switch\n        {\n            WorkflowScriptSyntax.Liquid => await _expressionEvaluator.EvaluateAsync(LiquidCondition, workflowContext, null),\n            WorkflowScriptSyntax.JavaScript => await _scriptEvaluator.EvaluateAsync(Condition, workflowContext),\n            _ => throw new NotSupportedException($\"The syntax {Syntax} isn't supported for WhileLoopTask.\")\n        };\n\n        return Outcome(loop ? \"Iterate\" : \"Done\");\n    }\n}\n","sourceCodeStart":40,"sourceCodeEnd":64,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Workflows/Activities/WhileLoopTask.cs#L40-L64","documentation":"WhileLoopTask evaluates its loop condition by switching on the activity's Syntax. Only Liquid (LiquidCondition) and JavaScript (Condition) evaluation are implemented; any other WorkflowScriptSyntax value hits the default arm and throws NotSupportedException, so the loop cannot decide whether to iterate or finish.","triggerScenarios":"Executing a WhileLoopTask whose Syntax property is not WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript (default/unset enum value, unknown syntax string deserialized from workflow JSON, or programmatic construction without Syntax).","commonSituations":"Hand-edited or migrated workflow definitions with stale syntax values; a new WorkflowScriptSyntax enum member not yet handled by WhileLoopTask; forgetting to set Syntax when creating the activity in code.","solutions":["Set Syntax to WorkflowScriptSyntax.Liquid and put the boolean condition in the LiquidCondition field.","Or set Syntax to WorkflowScriptSyntax.JavaScript and provide the boolean condition in the Condition field.","Repair the stored workflow definition if it holds a legacy/invalid syntax value.","If a new syntax member was added, rebuild/update OrchardCore.Workflows so ExecuteAsync handles it."],"exampleFix":"// before\nvar loop = new WhileLoopTask(); // Syntax unset -> throws\n// after\nvar loop = new WhileLoopTask\n{\n    Syntax = WorkflowScriptSyntax.JavaScript,\n    Condition = new JavaScriptExpression { Expression = \"variables.get('attempts') < 5\" }\n};","handlingStrategy":"validation","validationCode":"// before running the workflow\nif (whileLoopTask.Syntax is not (WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript))\n    throw new InvalidOperationException($\"WhileLoopTask requires Liquid or JavaScript syntax; got {whileLoopTask.Syntax}\");","typeGuard":"static bool IsSupportedSyntax(WorkflowScriptSyntax s) => s is WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript;","tryCatchPattern":"try { result = await activity.ExecuteAsync(workflowContext, activityContext); }\ncatch (NotSupportedException ex) { logger.LogError(ex, \"WhileLoopTask condition evaluation failed for syntax {Syntax}\", syntax); /* halt loop */ }","preventionTips":["Set Syntax explicitly on WhileLoopTask","Keep Condition/LiquidCondition consistent with the selected syntax","Validate workflow definitions at import time","Sync activity switch arms with any new WorkflowScriptSyntax members"],"tags":["workflows","unsupported-enum-value","script-syntax","orchardcore"],"backgroundTag":"unsupported-enum-value","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}