You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
==* and !=* with null parse, then throw when the query runs #210
==* and !=* with null parse with no error, then throw when the query runs. All other string operators refuse null at parse with a QueryKitParsingException.
Repro (QueryKit 1.16.2, Npgsql EF Core 10.0.0)
publicclassItem{publicintId{get;set;}publicstring?Title{get;set;}}varpredicate=FilterParser.ParseFilter<Item>("Title ==* null");// no exceptionrows.AsQueryable().Where(predicate).Count();// NullReferenceExceptiondb.Items.ApplyQueryKitFilter("Title ==* null").ToQueryString();// InvalidOperationException
Filter
In memory
EF Core ToQueryString()
Title == null
OK
OK
Title != null
OK
OK
Title ==* null
NullReferenceException
InvalidOperationException: "An exception was thrown while attempting to evaluate a LINQ query parameter expression."
QueryKitParsingException: "The '@=*' operator does not accept a null value. Use '==' or '!=' to compare with null."
The case-insensitive comparison calls ToLower() (or ToUpper()) on the null value. In an API, the client gets a 500 for a filter that QueryKit accepted.
Proposal
Make ==* and !=* refuse null at parse, with the same QueryKitParsingException and message as the other operators. Do not read ==* null as == null. One rule for each case-insensitive operator is easier for a client to learn.
A downstream app now walks the parsed expression to find a method call on a null constant, and returns a 400. This fix removes that check.
Activity
fix(filter): reject null for ==* and !=*