OrchardCMS/OrchardCore · error · ArgumentException
Unsupported range value type
Error message
Unsupported range value type: {type} What it means
Within the numeric branch of RangeQueryProvider.CreateQuery, the provider tries to read both bounds as long and then as double. If the JSON value kind is Number but neither parse succeeds (e.g. decimal values beyond double, or malformed numeric JSON), it throws ArgumentException with the unsupported type name. Only integral and double numeric ranges are supported.
Solutions
- Round or simplify the bound values so they fit in a .NET double (or long for integral bounds).
- If the field is actually textual, express bounds as JSON strings so the TermRangeQuery branch is used.
- Pre-parse/normalize numbers in the calling code before invoking CreateQuery.
Example fix
// before
{"Price": {"type": "range", "gt": 10.000000000000000000000000001, "lt": 20.000000000000000000000000002}}
// after
{"Price": {"type": "range", "gt": 10.0, "lt": 20.0}} Defensive patterns
Strategy: validation
Validate before calling
if (decimal.TryParse(bound.ToString(), out var d) && d is >= (decimal)double.MinValue and <= (decimal)double.MaxValue) { /* safe as numeric bound */ } Type guard
static bool IsParsableNumber(JsonNode n) => n.GetValueKind() == JsonValueKind.Number && (n.AsValue().TryGetValue<long>(out _) || n.AsValue().TryGetValue<double>(out _));
Try / catch
try { var q = provider.CreateQuery(node); } catch (ArgumentException ex) when (ex.Message.StartsWith("Unsupported range value type")) { // fall back to a string TermRangeQuery } Prevention
- Keep numeric range bounds within long or double precision.
- Avoid pasting culture-formatted or arbitrary-precision decimals into queries.
- Unit-test range queries with the extreme values your fields can hold.
When it happens
Trigger: A range node whose nodeKind is JsonValueKind.Number but whose bounds cannot be parsed as long or double, e.g. very high-precision decimals like {"gt": 0.123456789012345678901234567890}.
Common situations: Arbitrary-precision decimal literals in query JSON; culture-formatted numbers pasted into queries; BigInteger-like values exceeding double range.
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
- Unsupported range value type
- Lower and upper bound range types don't match
- Invalid range query
- Lower and upper bound range types don't match
- Invalid range query
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/d8cbf2627eccb319.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/RangeQueryProvider.cs:79
throw new ArgumentException("Lower and upper bound range types don't match");
}
switch (nodeKind)
{
case JsonValueKind.Number:
if (gt.AsValue().TryGetValue<long>(out var minInt) &&
lt.AsValue().TryGetValue<long>(out var maxInt))
{
rangeQuery = NumericRangeQuery.NewInt64Range(field, minInt, maxInt, includeLower, includeUpper);
}
else if (gt.AsValue().TryGetValue<double>(out var minFloat) &&
lt.AsValue().TryGetValue<double>(out var maxFloat))
{
rangeQuery = NumericRangeQuery.NewDoubleRange(field, minFloat, maxFloat, includeLower, includeUpper);
}
else
{
throw new ArgumentException($"Unsupported range value type: {type}");
}
break;
case JsonValueKind.String:
var minString = gt?.Value<string>();
var maxString = lt?.Value<string>();
rangeQuery = TermRangeQuery.NewStringRange(field, minString, maxString, includeLower, includeUpper);
break;
default: throw new ArgumentException($"Unsupported range value type: {type}");
}
if (boost != null)
{
rangeQuery.Boost = boost.Value;
}
return rangeQuery;View on GitHub (pinned to 4306c0717f)