{"record":{"id":"492d891cf5ef0eee","repo":"OrchardCMS/OrchardCore","slug":"invalid-wildcard-query-wildcardqueryprovider","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/WildcardQueryProvider.cs","lineNumber":41,"sourceCode":"\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":23,"sourceCodeEnd":45,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Lucene.Core/QueryProviders/WildcardQueryProvider.cs#L23-L45","documentation":"Reached at the end of Lucene's WildcardQueryProvider.CreateQuery when the query fragment matched neither the single-term shape nor the object shape with a 'value' property (and any earlier validation already passed). It indicates a wildcard query clause whose JSON structure is unrecognized — for example an array of terms or a property other than 'value'/'boost'.","triggerScenarios":"Calling CreateQuery with a wildcard query whose value is not a string or object, e.g. {\"wildcard\": {\"Rating\": 5}} or a null/numeric wildcard value.","commonSituations":"Assuming wildcard queries accept numbers or pre-serialized values; dynamic query construction that doesn't coerce values to strings.","solutions":["Convert the value to a string: {\"wildcard\": {\"Rating\": \"5\"}}.","Use the object form with \"value\": {\"Rating\": {\"value\": \"5*\"}}.","Coerce/validate JSON values to string kind before building the query."],"exampleFix":"// before\n{\"wildcard\": {\"Price\": 199}}\n// after\n{\"wildcard\": {\"Price\": \"199*\"}}","handlingStrategy":"validation","validationCode":"if (wild.ValueKind != JsonValueKind.String && wild.ValueKind != JsonValueKind.Object)\n    throw new InvalidOperationException(\"Wildcard value must be a string or an object with 'value'.\");","typeGuard":"static bool IsValidWildcardValue(JsonElement el) =>\n    el.ValueKind == JsonValueKind.String ||\n    (el.ValueKind == JsonValueKind.Object && el.TryGetProperty(\"value\", out var v) && v.ValueKind == JsonValueKind.String);","tryCatchPattern":"catch (ArgumentException ex) when (ex.Message == \"Invalid wildcard query\")\n{\n    // coerce value to string and retry or reject query\n}","preventionTips":["Coerce numeric/boolean wildcard values to strings before building queries.","Remember Lucene wildcards operate on text; stringify numbers explicitly.","Validate query JSON shape in a central query-builder helper."],"tags":["lucene","query","wildcard"],"backgroundTag":"invalid-argument-value","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}