OrchardCMS/OrchardCore · error · ArgumentException

Missing value in wildcard query

Error message

Missing value in wildcard query

What it means

WildcardQueryProvider accepts either a simple string value or an object with a 'value' property. When an object is given but lacks the 'value' property, the provider throws ArgumentException because it cannot construct the Lucene WildcardQuery term.

Solutions

  1. Add the "value" property to the wildcard object: {"Title": {"value": "app*"}}.
  2. Or use the simple string form: {"Title": "app*"}.
  3. Validate the wildcard JSON contains "value" before dispatching the query.

Example fix

// before
{"wildcard": {"Title": {"boost": 2.0}}}
// after
{"wildcard": {"Title": {"value": "app*", "boost": 2.0}}}
Defensive patterns

Strategy: validation

Validate before calling

if (wild.ValueKind == JsonValueKind.Object && !wild.TryGetProperty("value", out _))
    throw new InvalidOperationException("Wildcard object requires a 'value' property.");

Type guard

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

Try / catch

catch (ArgumentException ex) when (ex.Message.Contains("Missing value in wildcard"))
{
    // fix the query payload or return a 400 with a clear message
}

Prevention

When it happens

Trigger: Calling CreateQuery with a wildcard query like {"wildcard": {"Title": {"boost": 2}}} where the object has boost/other keys but no "value" key.

Common situations: Copy-pasting an Elasticsearch-style wildcard JSON with only options and forgetting the value; renaming the value key (e.g. to 'pattern') in custom tooling.

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/85a7c85f61a40941. Report an issue: GitHub.

Appendix: source

Thrown at src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/WildcardQueryProvider.cs:29

    {
        if (type != "wildcard")
        {
            return null;
        }

        var first = query.First();

        switch (first.Value.GetValueKind())
        {
            case JsonValueKind.String:
                return new WildcardQuery(new Term(first.Key, first.Value.ToString()));

            case JsonValueKind.Object:
                var obj = first.Value.AsObject();

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

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

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

                return wildCardQuery;

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

View on GitHub (pinned to 4306c0717f)