OrchardCMS/OrchardCore · error · NotSupportedException

The syntax isn't supported for WhileLoopTask.

Error message

The syntax {Syntax} isn't supported for WhileLoopTask.

What it means

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.

Solutions

  1. Set Syntax to WorkflowScriptSyntax.Liquid and put the boolean condition in the LiquidCondition field.
  2. Or set Syntax to WorkflowScriptSyntax.JavaScript and provide the boolean condition in the Condition field.
  3. Repair the stored workflow definition if it holds a legacy/invalid syntax value.
  4. If a new syntax member was added, rebuild/update OrchardCore.Workflows so ExecuteAsync handles it.

Example fix

// before
var loop = new WhileLoopTask(); // Syntax unset -> throws
// after
var loop = new WhileLoopTask
{
    Syntax = WorkflowScriptSyntax.JavaScript,
    Condition = new JavaScriptExpression { Expression = "variables.get('attempts') < 5" }
};
Defensive patterns

Strategy: validation

Validate before calling

// before running the workflow
if (whileLoopTask.Syntax is not (WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript))
    throw new InvalidOperationException($"WhileLoopTask requires Liquid or JavaScript syntax; got {whileLoopTask.Syntax}");

Type guard

static bool IsSupportedSyntax(WorkflowScriptSyntax s) => s is WorkflowScriptSyntax.Liquid or WorkflowScriptSyntax.JavaScript;

Try / catch

try { result = await activity.ExecuteAsync(workflowContext, activityContext); }
catch (NotSupportedException ex) { logger.LogError(ex, "WhileLoopTask condition evaluation failed for syntax {Syntax}", syntax); /* halt loop */ }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13). Data as JSON: /api/errors/39febc6975d0c960. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Workflows/Activities/WhileLoopTask.cs:58

        set => SetProperty(value);
    }

    public WorkflowScriptSyntax Syntax
    {
        get => GetProperty(() => WorkflowScriptSyntax.JavaScript);
        set => SetProperty(value);
    }

    public override IEnumerable<Outcome> GetPossibleOutcomes(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
        => Outcome(S["Iterate"], S["Done"]);

    public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext)
    {
        var loop = Syntax switch
        {
            WorkflowScriptSyntax.Liquid => await _expressionEvaluator.EvaluateAsync(LiquidCondition, workflowContext, null),
            WorkflowScriptSyntax.JavaScript => await _scriptEvaluator.EvaluateAsync(Condition, workflowContext),
            _ => throw new NotSupportedException($"The syntax {Syntax} isn't supported for WhileLoopTask.")
        };

        return Outcome(loop ? "Iterate" : "Done");
    }
}

View on GitHub (pinned to 4306c0717f)