{"record":{"id":"3f0c8bb4fddbeb17","repo":"OrchardCMS/OrchardCore","slug":"missing-value-in-wildcard-query","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/Filters/WildcardFilterProvider.cs","lineNumber":38,"sourceCode":"        }\n\n        var queryObj = filter.AsObject();\n        var first = queryObj.First();\n\n        // A term query has only one member, which can either be a string or an object\n        WildcardQuery wildcardQuery;\n\n        switch (first.Value.GetValueKind())\n        {\n            case JsonValueKind.String:\n                wildcardQuery = new WildcardQuery(new Term(first.Key, first.Value.ToString()));\n                break;\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                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                break;\n            default: throw new ArgumentException(\"Invalid wildcard query\");\n        }\n\n        booleanQuery.Add(wildcardQuery, Occur.MUST);\n        var queryFilter = new QueryWrapperFilter(wildcardQuery);\n\n        return new FilteredQuery(booleanQuery, queryFilter);\n    }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/WildcardFilterProvider.cs#L20-L56","documentation":"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.","triggerScenarios":"Calling CreateFilteredQuery with a filter like {\"title\": {\"boost\": 2}} — an object that is missing the required \"value\" key.","commonSituations":"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.","solutions":["Add the required \"value\" string property to the object: {\"title\": {\"value\": \"foo*\"}}.","Check for key typos (\"value\" exactly, case-sensitive).","Validate that obj[\"value\"] exists and is a string before invoking the provider."],"exampleFix":"// before\n{\"title\": {\"boost\": 2}}\n// after\n{\"title\": {\"value\": \"foo*\", \"boost\": 2}}","handlingStrategy":"validation","validationCode":"if (filter.Value.ValueKind == JsonValueKind.Object && !filter.Value.TryGetProperty(\"value\", out _))\n    throw new ArgumentException(\"wildcard filter object requires a 'value' property\");","typeGuard":"static bool HasWildcardValue(JsonElement el) =>\n    el.ValueKind == JsonValueKind.Object && el.TryGetProperty(\"value\", out var v) && v.ValueKind == JsonValueKind.String;","tryCatchPattern":"try { var query = provider.CreateFilteredQuery(context, filter); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Missing value\"))\n{ return BadRequest(\"Wildcard filter requires { \\\"value\\\": \\\"pattern*\\\" }.\"); }","preventionTips":["Always include the exact key \"value\" in object-form wildcard filters.","Use constants for filter keys instead of raw literals to avoid typos.","Validate option-only objects before submission."],"tags":["lucene","wildcard","missing-field"],"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"}