fix: accept null and list-shaped boolean filter combinators - #475
Merged
Merged
Conversation
`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
Contributor
|
🚀 Thank you for your contribution! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #472.
and,orandnotare generated as nullable[<Resource>FilterInput!]fields, so{and: null},{or: null},{not: null},{not: []}and anotlist with more than one entry all pass schema validation.AshGraphql.Graphql.FilterHandlers.process_boolean_filter/5only had clauses fornotwith a single-element list or a map and forand/orwith a list, so each of those inputs raisedFunctionClauseErrorinside the resolver and the client received "Something went wrong".nullcombinator and an emptynotlist are now ignored, the same way an emptyand/orlist is already dropped before reaching Ash.notlist with several entries is passed through asnot: [...], which Ash reads as the negated conjunction (not (a and b)). The single-entry behaviour is unchanged.Tests:
test/read_test.exsgains a "boolean filter combinators" describe block covering the null cases, the emptynotlist, a multi-entrynotand the existing single-entrynot. Onmainthe first three raiseFunctionClauseErrorinprocess_boolean_filter/5; with the change all four pass. Full suite 443/443 onmainand 428/428 with the patch applied to v1.11.0.mix format --check-formatted,mix credo --strict,mix sobelowandmix dialyzerclean.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.