{"record":{"id":"f22546e128aafeff","repo":"OrchardCMS/OrchardCore","slug":"unrecognized-fluidvalue","errorCode":null,"errorMessage":"Unrecognized FluidValue","messagePattern":"Unrecognized FluidValue","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Liquid/Filters/JsonFilter.cs","lineNumber":47,"sourceCode":"                return ValueTask.FromResult<FluidValue>(new StringValue(JConvert.SerializeObject(input.ToNumberValue(), formatting)));\n\n            case FluidValues.DateTime:\n            case FluidValues.Dictionary:\n            case FluidValues.Object:\n                return ValueTask.FromResult<FluidValue>(new StringValue(JConvert.SerializeObject(input.ToObjectValue(), formatting)));\n\n            case FluidValues.String:\n                var stringValue = input.ToStringValue();\n\n                if (string.IsNullOrWhiteSpace(stringValue))\n                {\n                    return ValueTask.FromResult(input);\n                }\n\n                return ValueTask.FromResult<FluidValue>(new StringValue(JConvert.SerializeObject(stringValue, formatting)));\n        }\n\n        throw new NotSupportedException(\"Unrecognized FluidValue\");\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":50,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Liquid/Filters/JsonFilter.cs#L29-L50","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Check the value being piped into the `json` filter is a supported type (string, number, boolean, date, array, object) and not nil","Assign the value first and use `{% if x != null %}{{ x | json }}{% endif %}` to avoid nil input","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","Update to a patched Orchard Core version if a FluidValue subtype is missing a conversion branch"],"exampleFix":"// before\n{{ somePossiblyNilValue | json }}\n// after\n{% if somePossiblyNilValue != null %}{{ somePossiblyNilValue | json }}{% else %}null{% endif %}","handlingStrategy":"type-guard","validationCode":"{% if myValue != null %}{{ myValue | json }}{% endif %}","typeGuard":"bool IsJsonFilterSafe(object v) => v is string or bool or DateTime or IEnumerable<object> or decimal or int or double;","tryCatchPattern":"try { output = RenderLiquid(template); } catch (NotSupportedException ex) when (ex.Message == \"Unrecognized FluidValue\") { log.Warn(\"json filter received unsupported FluidValue\"); output = null; }","preventionTips":["Never pipe raw nil/unknown variables into the json filter","Guard template variables with null checks before using json","After Fluid/Orchard upgrades, smoke-test templates using json","Keep custom FluidValue types out of generic templates or handle them explicitly"],"tags":["liquid","fluid","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}