elsa-workflows/elsa-core · error · OutputConversionException
Output conversion failed during result validation
Error message
Output conversion failed during result validation
What it means
An OutputConversionException thrown while validating the result of an output conversion. The converted value was null but the output descriptor's destination type does not allow null (AllowsNull is false). Elsa throws this so activity output contracts are enforced before downstream activities consume the value.
Solutions
- Ensure the activity actually sets the output value before completing (set the Output/Output<T> property in ExecuteAsync).
- Fix the expression/input that evaluates to null (check variable names, default values).
- If null is a legitimate result, mark the output as nullable (AllowsNull=true on the Output descriptor or use nullable type).
- Add validation before completion to fail fast with a clearer message.
Example fix
// before
public Output<string> Result { get; set; } = default!;
// ExecuteAsync never sets Result -> null conversion failure
// after
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
context.Set(Result, someValue ?? string.Empty); // or declare Output<string?> if null is valid
} Defensive patterns
Strategy: validation
Validate before calling
// before completing the activity
var value = computedResult;
if (value is null && !outputDescriptor.AllowsNull)
throw new InvalidOperationException("Output value must not be null; set the output or mark it nullable."); Try / catch
// catch Elsa.Workflows.Core.Exceptions.OutputConversionException around activity execution
catch (OutputConversionException ex) when (ex.Stage == OutputConversionFailureStage.ResultValidation)
{
logger.LogError(ex, "Output {Output} returned null for {ActivityType}", ex.OutputName, ex.ActivityType);
} Prevention
- Always set declared outputs in ExecuteAsync before completion.
- Declare outputs nullable (Output<T?>) when null is a valid result.
- Test custom activities end-to-end so conversion validation runs.
When it happens
Trigger: An activity produces/sets an output whose value converts (or resolves) to null, while the output descriptor for the target output declares a non-nullable destination type or AllowNull=false; thrown from output conversion/result validation in ActivityExecutionContext.
Common situations: An expression evaluated to null (missing variable, empty input), a C# activity output property left unset while declared non-nullable, custom activities with output descriptors copied from nullable types but declared non-nullable, or a converter returning null for a failed parse.
Related errors
- Activity not found.
- is required.
- Output conversion failed during destination resolution
- Activity type not found
- Activity descriptor not found
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/db3b2d5731cbd32c.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Workflows.Core/Contexts/ActivityExecutionContext.cs:815
if (destination == null)
{
throw new OutputConversionException(
output.Converter.Id,
OutputConversionFailureStage.Resolution,
Activity.Id,
Activity.Type,
resolvedOutputName,
output.MemoryBlockReference().Id,
sourceType,
null);
}
if (value == null)
{
if (!destination.AllowsNull)
{
throw new OutputConversionException(
output.Converter.Id,
OutputConversionFailureStage.ResultValidation,
Activity.Id,
Activity.Type,
resolvedOutputName,
destination.Id,
sourceType,
destination.Type);
}
ExpressionExecutionContext.SetBoundValue(output, null);
return;
}
var converterInvoker = GetRequiredService<IOutputConverterInvoker>();
var convertedValue = converterInvoker.Invoke(this, output, resolvedOutputName, sourceType, value, destination);
ExpressionExecutionContext.SetBoundValue(output, convertedValue);
}View on GitHub (pinned to fe9217bdfa)