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
Feature request: setting to ignore or throw for filters and sorts on prevented properties #112
Add a setting that selects what QueryKit does when a filter or a sort uses a property with PreventFilter() or PreventSort():
Ignore (default): QueryKit removes the filter clause or skips the sort clause. The rest of the filter or sort still runs.
Throw: QueryKit throws a QueryKitException subclass that names the property.
Current behavior
After the property resolver work, a prevented property is always ignored:
The parser removes a prevented filter clause. This is true for the member name and for the query name.
SortParser skips a prevented sort clause.
Before that work, the behavior was not the same for all forms. A property with both PreventFilter() and PreventSort() threw InvalidOperationException (wrapped in a ParsingException) when the filter used its query name. With the member name, the same clause was removed.
Why a setting
Some APIs want to silently ignore fields that a client cannot use. Other APIs want to return a 400 so that the client knows that its filter or sort had no effect. Ignore stays the default, so current users see no change.
The "Current behavior" section above is out of date. 1.16.2 has IgnoredClauseBehavior, and its default ReplaceWithTrue turns a prevented clause into true. A client that filters on a prevented property gets every row, and gets no error.
Rows: abc, "abc", abc", [a], and secret row (the only row with Secret = "x").
Filter
Setting
Result
Secret == "x"
ReplaceWithTrue (default)
5 rows. The client asked for 1 row.
Secret == "x" || Title == "abc"
ReplaceWithTrue
5 rows
Secret == "x" && Title == "abc"
ReplaceWithTrue
1 row (abc)
Secret == "x" || Title == "abc"
Remove
1 row (abc). The secret row is missing, and the client does not know why.
The app wants a 400 here. It cannot use PreventFilter for this, so it walks the parsed expression with an ExpressionVisitor and throws when the expression reads the member. It does this for two members: a concurrency version (Postgres has no order for xid, so a range or a sort fails with a 500), and a member that the handler fills after the query.
Suggestion on the shape
IgnoredClauseBehavior already exists, so a third value Throw can be the setting. Then no new PreventedPropertyBehavior setting is necessary. With AllowUnknownProperties = false, an unknown property already throws UnknownFilterPropertyException. A prevented property can throw a subclass of QueryKitException that has a PropertyName property (see #209).
Activity
pdevito3 commentedon Nov 1, 2026
Examples from a downstream app (QueryKit 1.16.2)
The "Current behavior" section above is out of date. 1.16.2 has
IgnoredClauseBehavior, and its defaultReplaceWithTrueturns a prevented clause intotrue. A client that filters on a prevented property gets every row, and gets no error.Rows:
abc,"abc",abc",[a], andsecret row(the only row withSecret = "x").Secret == "x"ReplaceWithTrue(default)Secret == "x" || Title == "abc"ReplaceWithTrueSecret == "x" && Title == "abc"ReplaceWithTrueabc)Secret == "x" || Title == "abc"Removeabc). Thesecret rowis missing, and the client does not know why.The app wants a 400 here. It cannot use
PreventFilterfor this, so it walks the parsed expression with anExpressionVisitorand throws when the expression reads the member. It does this for two members: a concurrency version (Postgres has no order forxid, so a range or a sort fails with a 500), and a member that the handler fills after the query.Suggestion on the shape
IgnoredClauseBehavioralready exists, so a third valueThrowcan be the setting. Then no newPreventedPropertyBehaviorsetting is necessary. WithAllowUnknownProperties = false, an unknown property already throwsUnknownFilterPropertyException. A prevented property can throw a subclass ofQueryKitExceptionthat has aPropertyNameproperty (see #209).feat(config): add IgnoredClauseBehavior.Throw for prevented properties