elsa-workflows/elsa-core · error · ArgumentOutOfRangeException

Unrecognized FluidValue

Error message

Unrecognized FluidValue

What it means

InputToString in Base64Filter converts a Liquid (FluidValue) input to its string representation before base64 encoding. It switches on the FluidValue type and throws ArgumentOutOfRangeException when the value type is none of the handled kinds (e.g. FluidValues.Blank or future FluidValue kinds), signaling the filter received a value type it does not know how to stringify.

Solutions

  1. Check what value is being piped into the base64 filter and ensure it is a string, number, boolean, array, or object
  2. Guard the template with an if/blank check before applying the filter, e.g. {% if input %}{{ input | base64 }}{% endif %}
  3. Catch ArgumentOutOfRangeException around expression evaluation or disable strict mode so it degrades gracefully
  4. If caused by a Fluid package upgrade, update the Elsa.Expressions.Liquid package so the switch covers new FluidValue kinds

Example fix

// before
{% if input %}{{ input | base64 }}{% endif %}
// after (guard blank/empty explicitly)
{% unless input == blank %}{{ input | base64 }}{% endunless %}
Defensive patterns

Strategy: type-guard

Validate before calling

// before applying the filter
if (input == blank)
  return ""; // or skip base64

Type guard

{% if input != blank %}{{ input | base64 }}{% endif %}

Try / catch

try { result = Evaluate(template, model); }
catch (ArgumentOutOfRangeException ex) when (ex.Message.Contains("Unrecognized FluidValue")) { result = null; }

Prevention

When it happens

Trigger: Applying the base64 filter in a Liquid template to an input whose FluidValues kind is not Array, Boolean, Nil, Number, DateTime, Dictionary, Object, or String — most notably FluidValues.Blank, or a new FluidValue kind introduced by a Fluid library upgrade.

Common situations: Piping blank/empty values into {{ input | base64 }}, or upgrading the Fluid NuGet package so new FluidValue types reach the unhandled default case.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/modules/Elsa.Expressions.Liquid/Filters/Base64Filter.cs:39

            return new ValueTask<FluidValue>(NilValue.Instance);

        var bytes = Encoding.UTF8.GetBytes(text);
        var base64 = Convert.ToBase64String(bytes);

        return new ValueTask<FluidValue>(new StringValue(base64));
    }

    private static string? InputToString(FluidValue input, TemplateContext context)
    {
        return input.Type switch
        {
            FluidValues.Array => JsonSerializer.Serialize(input.Enumerate(context).Select(o => o.ToObjectValue())),
            FluidValues.Boolean => input.ToBooleanValue().ToString(),
            FluidValues.Nil => null,
            FluidValues.Number => input.ToNumberValue().ToString(CultureInfo.InvariantCulture),
            FluidValues.DateTime or FluidValues.Dictionary or FluidValues.Object => JsonSerializer.Serialize(input.ToObjectValue()),
            FluidValues.String => input.ToStringValue(),
            _ => throw new ArgumentOutOfRangeException(nameof(input), "Unrecognized FluidValue")
        };
    }
}

View on GitHub (pinned to fe9217bdfa)