OrchardCMS/OrchardCore · error · NotSupportedException

Unrecognized FluidValue

Error message

Unrecognized FluidValue

What it means

JsonFilter's Liquid 'json' filter only supports FluidValue types it explicitly recognizes (strings, numbers, booleans, arrays, objects, etc.). When the input FluidValue is of a type the filter has no conversion branch for, it throws NotSupportedException('Unrecognized FluidValue') as an internal invariant guard. It means the Liquid pipeline passed a FluidValue subtype the filter was not written to handle.

Solutions

  1. Check the value being piped into the `json` filter is a supported type (string, number, boolean, date, array, object) and not nil
  2. Assign the value first and use `{% if x != null %}{{ x | json }}{% endif %}` to avoid nil input
  3. Inspect the actual runtime type (add logging or dump the value without the filter) and extend the filter's switch in a custom module to handle it
  4. Update to a patched Orchard Core version if a FluidValue subtype is missing a conversion branch

Example fix

// before
{{ somePossiblyNilValue | json }}
// after
{% if somePossiblyNilValue != null %}{{ somePossiblyNilValue | json }}{% else %}null{% endif %}
Defensive patterns

Strategy: type-guard

Validate before calling

{% if myValue != null %}{{ myValue | json }}{% endif %}

Type guard

bool IsJsonFilterSafe(object v) => v is string or bool or DateTime or IEnumerable<object> or decimal or int or double;

Try / catch

try { output = RenderLiquid(template); } catch (NotSupportedException ex) when (ex.Message == "Unrecognized FluidValue") { log.Warn("json filter received unsupported FluidValue"); output = null; }

Prevention

When it happens

Trigger: Using the `json` Liquid filter with an input value that FluidValue.ToObjectValue() converts to a type not handled by the switch (e.g. a nil/null FluidValue, or a FluidValue subclass from a custom module that falls through all branches).

Common situations: Templates that pipe nil or unusual shapes into `json`; upgrading Fluid/Orchard Core versions where new FluidValue subtypes appear but the filter was not extended; custom FluidValue implementations in custom filters/modules.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/OrchardCore.Modules/OrchardCore.Liquid/Filters/JsonFilter.cs:47

                return ValueTask.FromResult<FluidValue>(new StringValue(JConvert.SerializeObject(input.ToNumberValue(), formatting)));

            case FluidValues.DateTime:
            case FluidValues.Dictionary:
            case FluidValues.Object:
                return ValueTask.FromResult<FluidValue>(new StringValue(JConvert.SerializeObject(input.ToObjectValue(), formatting)));

            case FluidValues.String:
                var stringValue = input.ToStringValue();

                if (string.IsNullOrWhiteSpace(stringValue))
                {
                    return ValueTask.FromResult(input);
                }

                return ValueTask.FromResult<FluidValue>(new StringValue(JConvert.SerializeObject(stringValue, formatting)));
        }

        throw new NotSupportedException("Unrecognized FluidValue");
    }
}

View on GitHub (pinned to 4306c0717f)