Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: errors messages on embedded forms multiply #107

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

rgraff
Copy link
Contributor

@rgraff rgraff commented Oct 10, 2023

The Enum.uniq() on error messages does address my initial bug, but I believe this fixes it at the source. When Ash.phoenix_form.synthesize_action_errors/3 is called recursively, the embedded form errors are added twice. This fixes the issue for me without the need for Enum.uniq() in the helper. My robust test suite passes and I did some manual testing in my app, but I don't know if this "fix" is appropriate for everyone.

Contributor checklist

  • Bug fixes include regression tests
  • Features include unit/acceptance tests

@@ -3509,8 +3509,7 @@ defmodule AshPhoenix.Form do
|> Enum.map(fn error ->
%{error | path: trail ++ error.path}
end)

further_errors = further_errors ++ Enum.reject(errors, &(&1.path == trail))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

further_errors and are concatenated below on line 3542

@rgraff rgraff changed the title fix: multiply error messages fix: errors messages on embedded forms multiply Oct 10, 2023
@zachdaniel
Copy link
Contributor

This makes sense to me, looks like the duplication was just a mechanical bug then, happy to merge this. Won't merge it now since its marked as a draft though.

@rgraff rgraff marked this pull request as ready for review October 10, 2023 22:03
@rgraff
Copy link
Contributor Author

rgraff commented Oct 10, 2023

I think it's possible--but I'm not sure how--for form errors that don't match any paths to be filtered out completely. Maybe give #mainliners a heads up on this one.

@zachdaniel
Copy link
Contributor

I'll drop a note in there, thanks for the fix!

@zachdaniel zachdaniel merged commit c93c606 into ash-project:main Oct 10, 2023
13 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.

2 participants