{"record":{"id":"85a7c85f61a40941","repo":"OrchardCMS/OrchardCore","slug":"missing-value-in-wildcard-query-wildcardqueryprovider","errorCode":null,"errorMessage":"Missing value in wildcard query","messagePattern":"Missing value in wildcard query","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/WildcardQueryProvider.cs","lineNumber":29,"sourceCode":"    {\n        if (type != \"wildcard\")\n        {\n            return null;\n        }\n\n        var first = query.First();\n\n        switch (first.Value.GetValueKind())\n        {\n            case JsonValueKind.String:\n                return new WildcardQuery(new Term(first.Key, first.Value.ToString()));\n\n            case JsonValueKind.Object:\n                var obj = first.Value.AsObject();\n\n                if (!obj.TryGetPropertyValue(\"value\", out var value))\n                {\n                    throw new ArgumentException(\"Missing value in wildcard query\");\n                }\n\n                var wildCardQuery = new WildcardQuery(new Term(first.Key, value.Value<string>()));\n\n                if (obj.TryGetPropertyValue(\"boost\", out var boost))\n                {\n                    wildCardQuery.Boost = boost.Value<float>();\n                }\n\n                return wildCardQuery;\n\n            default: throw new ArgumentException(\"Invalid wildcard query\");\n        }\n    }\n}\n","sourceCodeStart":11,"sourceCodeEnd":45,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/WildcardQueryProvider.cs#L11-L45","documentation":"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.","triggerScenarios":"Calling CreateQuery with a wildcard query like {\"wildcard\": {\"Title\": {\"boost\": 2}}} where the object has boost/other keys but no \"value\" key.","commonSituations":"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.","solutions":["Add the \"value\" property to the wildcard object: {\"Title\": {\"value\": \"app*\"}}.","Or use the simple string form: {\"Title\": \"app*\"}.","Validate the wildcard JSON contains \"value\" before dispatching the query."],"exampleFix":"// before\n{\"wildcard\": {\"Title\": {\"boost\": 2.0}}}\n// after\n{\"wildcard\": {\"Title\": {\"value\": \"app*\", \"boost\": 2.0}}}","handlingStrategy":"validation","validationCode":"if (wild.ValueKind == JsonValueKind.Object && !wild.TryGetProperty(\"value\", out _))\n    throw new InvalidOperationException(\"Wildcard object requires a 'value' property.\");","typeGuard":"static bool HasWildcardValue(JsonElement el) =>\n    el.ValueKind == JsonValueKind.String ||\n    (el.ValueKind == JsonValueKind.Object && el.TryGetProperty(\"value\", out _));","tryCatchPattern":"catch (ArgumentException ex) when (ex.Message.Contains(\"Missing value in wildcard\"))\n{\n    // fix the query payload or return a 400 with a clear message\n}","preventionTips":["Include \"value\" in every wildcard object form.","Prefer the simple string form {\"field\": \"pat*\"} when no boost is needed.","Lint user-submitted query JSON for required keys."],"tags":["lucene","query","wildcard"],"backgroundTag":"missing-required-argument","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}