Skip to content

Conversation

@DGollings
Copy link
Contributor

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

Somebody mixed query and params, and caused a minor error:

** (KeyError) key :class not found in: "conflict path and query params"

If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map

stacktrace:
(ash_json_api 1.4.45) lib/ash_json_api/error/error.ex:56: AshJsonApi.Error.to_json_api_errors/4
(ash_json_api 1.4.45) lib/ash_json_api/request.ex:186: anonymous fn/4 in AshJsonApi.Request.add_error/4
(elixir 1.18.4) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
(ash_json_api 1.4.45) lib/ash_json_api/request.ex:104: AshJsonApi.Request.from/7
(ash_json_api 1.4.45) lib/ash_json_api/controllers/get.ex:19: AshJsonApi.Controllers.Get.call/2

this should handle that nicely, the only downside is that it assumes all binary errors are validation errors but a quick (automated) search suggests they are

  • "conflict path and query params" - parameter validation
  • "no schema found" - missing schema
  • "Invalid filter included" - filter validation
  • "Invalid sort included" - sort validation
  • "invalid filter" - filter validation
  • "invalid sort [field]" - sort validation
  • "invalid sort string" - sort validation

[error]
end

def to_json_api_errors(domain, resource, error, type) when is_binary(error) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally speaking we should expect to be handling specific errors here that can implement a protocol. What are you doing that is ending up passing a string here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh if its something internal, then we should have those return InvalidQuery errors instead of strings. Could you make that change instead? 🙇

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, added a bunch of new errors and tests for those errors, plus a fallback for if anything ever hits the binary handler again (just in case)

@barnabasJ barnabasJ assigned barnabasJ and unassigned barnabasJ Oct 27, 2025
Copy link
Contributor

@barnabasJ barnabasJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@barnabasJ
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

@barnabasJ barnabasJ merged commit 4c06dad into ash-project:main Oct 27, 2025
23 checks passed
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.

3 participants