Skip to content

fix: accept null and list-shaped boolean filter combinators - #475

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
grempe:fix/boolean-filter-shapes
Sep 17, 2026
Merged

zachdaniel merged 1 commit into
ash-project:mainfrom
grempe:fix/boolean-filter-shapes

Conversation

@grempe

@grempe grempe commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Closes #472.

and, or and not are generated as nullable [<Resource>FilterInput!] fields, so {and: null}, {or: null}, {not: null}, {not: []} and a not list with more than one entry all pass schema validation. AshGraphql.Graphql.FilterHandlers.process_boolean_filter/5 only had clauses for not with a single-element list or a map and for and/or with a list, so each of those inputs raised FunctionClauseError inside the resolver and the client received "Something went wrong".

  • A null combinator and an empty not list are now ignored, the same way an empty and/or list is already dropped before reaching Ash.
  • A not list with several entries is passed through as not: [...], which Ash reads as the negated conjunction (not (a and b)). The single-entry behaviour is unchanged.

Tests: test/read_test.exs gains a "boolean filter combinators" describe block covering the null cases, the empty not list, a multi-entry not and the existing single-entry not. On main the first three raise FunctionClauseError in process_boolean_filter/5; with the change all four pass. Full suite 443/443 on main and 428/428 with the patch applied to v1.11.0. mix format --check-formatted, mix credo --strict, mix sobelow and mix dialyzer clean.

Found by an AI agent working with a human fuzz-testing their own application; the reproduction outside this repo is https://github.com/grempe/ash-fuzz-repros/blob/main/test/ash_graphql/null_boolean_filter_test.exs.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

`and`, `or` and `not` are nullable lists of the resource filter type, so
`{and: null}`, `{or: null}`, `{not: null}`, `{not: []}` and a `not` list
with more than one entry all pass schema validation, but
`process_boolean_filter/5` had no clause for them and the query crashed
with a `FunctionClauseError`. A null combinator and an empty `not` list are
now ignored, matching how an empty `and`/`or` list is already dropped, and a
`not` list with several entries is passed through as `not: [...]`, which Ash
reads as the negated conjunction.

Closes ash-project#472
@zachdaniel
zachdaniel merged commit cdc1408 into ash-project:main Sep 17, 2026
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A null, empty or multi-element boolean filter crashes the resolver

2 participants