elsa-workflows/elsa-core · error · Exception

is required.

Error message

{inputName} is required.

What it means

Thrown by Input<T>.Get when the resolved input value is null. It converts an implicit null dereference into an explicit error naming the input, enforcing that required inputs were actually supplied to the activity.

Solutions

  1. Supply the required input when starting/triggering the workflow (match the input name exactly).
  2. Provide a default value on the Input<T> declaration or in the activity definition.
  3. Make the input optional and null-check before use if absence is legitimate.
  4. Validate required workflow inputs at workflow start (e.g., input validation endpoint) to fail early.

Example fix

// before
public Input<string> OrderId { get; set; } = default!;
// started without OrderId -> "OrderId is required."

// after
public Input<string?> OrderId { get; set; } = default!;
// and guard:
var orderId = OrderId.Get(context);
if (string.IsNullOrEmpty(orderId)) orderId = "default-order";
Defensive patterns

Strategy: try-catch

Validate before calling

// before starting the workflow
foreach (var required in new[] { "OrderId" })
    if (!workflowInputs.ContainsKey(required))
        throw new ArgumentException($"Missing required workflow input '{required}'.");

Try / catch

try
{
    var orderId = OrderId.Get(context);
}
catch (Exception ex) when (ex.Message == $"{nameof(OrderId)} is required.")
{
    // handle missing input: use default, compensate, or fail with guidance
}

Prevention

When it happens

Trigger: Calling input.Get(context) (or accessing a required Input<T> property) when no value was set - the workflow was started without providing this input, the expression evaluating it returned null, or the input was never assigned in the designer.

Common situations: HTTP/workflow starters omitting a required workflow input key; expression inputs referencing missing variables; callers using nullable workflow input dictionaries that skip absent keys; default values removed from the activity definition.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/modules/Elsa.Workflows.Core/Extensions/InputExtensions.cs:45

        /// <summary>
        /// Returns the value of the specified input, or a default value if the input is not found.
        /// </summary>
        public T? GetOrDefault(ExpressionExecutionContext context, Func<T>? defaultValue = default)
        {
            var value = context.Get(input);
            return value != null ? value : defaultValue != null ? defaultValue.Invoke() : default;
        }

        /// <summary>
        /// Returns the value of the specified input.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="inputName">The name of the input.</param>
        /// <returns>The value of the specified input.</returns>
        /// <exception cref="Exception">Throws an exception if the input is not found.</exception>
        public T Get(ActivityExecutionContext context, [CallerArgumentExpression("input")] string? inputName = default)
        {
            return context.Get(input) ?? throw new Exception($"{inputName} is required.");
        }

        /// <summary>
        /// Returns the value of the specified input.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="inputName">The name of the input.</param>
        /// <returns>The value of the specified input.</returns>
        /// <exception cref="Exception">Throws an exception if the input is not found.</exception>
        public T Get(ExpressionExecutionContext context, [CallerArgumentExpression("input")] string? inputName = default)
        {
            return context.Get(input) ?? throw new Exception($"{inputName} is required.");
        }
    }
}

View on GitHub (pinned to fe9217bdfa)