{"record":{"id":"87d2b8c6f43c9caf","repo":"OrchardCMS/OrchardCore","slug":"invalid-wildcard-query-wildcardfilterprovider","errorCode":null,"errorMessage":"Invalid wildcard query","messagePattern":"Invalid wildcard query","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/WildcardFilterProvider.cs","lineNumber":49,"sourceCode":"                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    }\n}\n","sourceCodeStart":31,"sourceCodeEnd":58,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/Filters/WildcardFilterProvider.cs#L31-L58","documentation":"This is the fall-through case of WildcardFilterProvider.CreateFilteredQuery: the field's JSON value is neither a scalar string nor an object with a \"value\" property (e.g. an array, number, or boolean), so no wildcard query can be constructed and it throws.","triggerScenarios":"Calling CreateFilteredQuery with a filter like {\"title\": [\"a\", \"b\"]} or {\"title\": 123} — any value type other than string or the supported object form.","commonSituations":"Reusing terms-query JSON for wildcard filters; numeric wildcard patterns unquoted; lists of patterns supplied as an array which the provider does not support.","solutions":["Provide the pattern as a JSON string: {\"title\": \"foo*\"}.","Or use the object form with \"value\": {\"title\": {\"value\": \"foo*\"}}.","If multiple patterns are needed, build a bool filter with several wildcard filters instead of an array."],"exampleFix":"// before\n{\"title\": [\"foo*\", \"bar*\"]}\n// after\n{\"title\": {\"value\": \"foo*\"}}","handlingStrategy":"validation","validationCode":"var k = filter.Value.ValueKind;\nif (k is not (JsonValueKind.String or JsonValueKind.Object))\n    throw new ArgumentException(\"wildcard filter value must be a string or an object with 'value'\");","typeGuard":"static bool IsWildcardShape(JsonElement el) =>\n    el.ValueKind == JsonValueKind.String ||\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) { return BadRequest($\"Invalid wildcard filter: {ex.Message}\"); }","preventionTips":["Send wildcard patterns as strings, one pattern per filter.","Combine multiple patterns via bool filters, not arrays.","Schema-validate filter payloads before dispatch."],"tags":["lucene","wildcard","query-validation"],"backgroundTag":"invalid-argument-format","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"}