OrchardCMS/OrchardCore · error · ArgumentException

Missing value in wildcard query

Error message

Missing value in wildcard query

What it means

WildcardFilterProvider.CreateFilteredQuery accepts an object form for wildcard filters with a required 'value' property. When the object under the field name lacks 'value', the provider cannot build a WildcardQuery and throws this ArgumentException.

Solutions

  1. Add the required "value" string property to the object: {"title": {"value": "foo*"}}.
  2. Check for key typos ("value" exactly, case-sensitive).
  3. Validate that obj["value"] exists and is a string before invoking the provider.

Example fix

// before
{"title": {"boost": 2}}
// after
{"title": {"value": "foo*", "boost": 2}}
Defensive patterns

Strategy: validation

Validate before calling

if (filter.Value.ValueKind == JsonValueKind.Object && !filter.Value.TryGetProperty("value", out _))
    throw new ArgumentException("wildcard filter object requires a 'value' property");

Type guard

static bool HasWildcardValue(JsonElement el) =>
    el.ValueKind == JsonValueKind.Object && el.TryGetProperty("value", out var v) && v.ValueKind == JsonValueKind.String;

Try / catch

try { var query = provider.CreateFilteredQuery(context, filter); }
catch (ArgumentException ex) when (ex.Message.Contains("Missing value"))
{ return BadRequest("Wildcard filter requires { \"value\": \"pattern*\" }."); }

Prevention

When it happens

Trigger: Calling CreateFilteredQuery with a filter like {"title": {"boost": 2}} — an object that is missing the required "value" key.

Common situations: Hand-written filter JSON with a typo like "val" or "values" instead of "value"; building the object programmatically and forgetting to set the value; copying match-query syntax into a wildcard filter.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/WildcardFilterProvider.cs:38

        }

        var queryObj = filter.AsObject();
        var first = queryObj.First();

        // A term query has only one member, which can either be a string or an object
        WildcardQuery wildcardQuery;

        switch (first.Value.GetValueKind())
        {
            case JsonValueKind.String:
                wildcardQuery = new WildcardQuery(new Term(first.Key, first.Value.ToString()));
                break;
            case JsonValueKind.Object:
                var obj = first.Value.AsObject();

                if (!obj.TryGetPropertyValue("value", out var value))
                {
                    throw new ArgumentException("Missing value in wildcard query");
                }

                wildcardQuery = new WildcardQuery(new Term(first.Key, value.Value<string>()));

                if (obj.TryGetPropertyValue("boost", out var boost))
                {
                    wildcardQuery.Boost = boost.Value<float>();
                }

                break;
            default: throw new ArgumentException("Invalid wildcard query");
        }

        booleanQuery.Add(wildcardQuery, Occur.MUST);
        var queryFilter = new QueryWrapperFilter(wildcardQuery);

        return new FilteredQuery(booleanQuery, queryFilter);
    }

View on GitHub (pinned to 4306c0717f)