Skip to content

==* and !=* with null parse, then throw when the query runs #210

Closed

Description

@pdevito3

Summary

==* 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)

public class Item { public int Id { get; set; } public string? Title { get; set; } }

var predicate = FilterParser.ParseFilter<Item>("Title ==* null");   // no exception
rows.AsQueryable().Where(predicate).Count();                        // NullReferenceException
db.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."
Title !=* null NullReferenceException The same as ==*
Title @= null, @=*, _=, _=*, _-=, _-=*, !@=*, !_=*, !_-=* QueryKitParsingException 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

  1. added a commit that references this issue on Nov 2, 2026
    03bacf3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions