fix: build the InvalidFilterValue detail without the error's message - #458
Merged
zachdaniel merged 1 commit intoSep 24, 2026
Merged
Conversation
`Ash.Error.Query.InvalidFilterValue.message/1` interpolates `context`, and ash_postgres puts the whole Ecto query there when a filter value cannot be cast. Rendering it as the JSON:API `detail` sent that query, with file paths and bindings, to the client: `GET /posts?filter[id]=not-a-uuid` answered with a detail of several thousand characters. The detail is now built from the value, with the `message` field appended only when it is a plain string, the same way the AshGraphql, AshLua and AshAi renderers do.
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.
Follows up on your request in ash-project/ash_postgres#863.
The
InvalidFilterValueimpl added in 9f86eba rendersAsh.Error.Query.InvalidFilterValue.message/1as thedetail, andmessage/1interpolatescontext. ash_postgres puts the whole Ecto query incontextwhen a filter value cannot be cast, so onmain,GET /posts?filter[id]=not-a-uuidagainst a Postgres resource answers with adetailof about 3,400 characters, including the query, file paths and bindings. It isn't in a release yet (1.7.1 has no impl for this error).The
detailis now built from the value, with themessagefield appended only when it is a plain string, the same way the AshGraphql (#477), AshLua and AshAi renderers do it. The code, title, status andmetaare unchanged.detailonmainfilter[id]=not-a-uuid(Postgres)Invalid filter value `"not-a-uuid"` supplied in `%{offset: nil, select: %Ecto.Query.SelectExpr{...(3,407 characters)Invalid filter value "not-a-uuid"filter[title][in]=xInvalid filter value `title in "x"`: No matching types. ...Invalid filter value title in "x": No matching types. ...Tests: two cases in
test/acceptance/error_validation_test.exs, one with acontextcontaining a marker that must not appear in thedetail, and one with a plain-string message. Both fail onmainand pass with the change. Full suite 407 passed, 15 skipped (405 onmain).mix format --check-formatted,mix credo --strictandmix sobeloware clean.mix dialyzerreports only theUnknown type: Ash.Resource.record/0warning inserializer.exthat it reports onmaintoo. As with #457, I ran everything withASH_VERSION=3.33.9, sincemix.lockonmainpoints at an ash commit that can't be fetched, and leftmix.lockout.End to end, against a Postgres-backed reproduction with released ash 3.33.9 and ash_postgres 2.13.1, the cast-error request above now answers the 33-character
detailshown, and nothing else in that suite changes.One question on the rest of the set from my comment on #863. That PR and #866 went in without the
no_value?commits, so the errors whose value isn't known still carryvalue: nil, and every renderer, this one included, shows it asnil. Would you like the rest as PRs: theno_value?option inash, the one-commit follow-ups for #863 and #866 (rebased ontomain), and the matching changes in AshGraphql, AshLua, AshAi and here? Or is leaving it as is fine?Contributor checklist
Leave anything that you believe does not apply unchecked.