AF
Ash Framework•2mo ago
lawik

Implementing error for Forbidden.Policy removed all the helpful debug assistance :D

Following the helpful warning here:
This error was unhandled because Ash.Error.Forbidden.Policy does not implement the `AshPhoenix.FormData.Error` protocol.
This error was unhandled because Ash.Error.Forbidden.Policy does not implement the `AshPhoenix.FormData.Error` protocol.
I did this:
defimpl AshPhoenix.FormData.Error, for: Ash.Error.Forbidden.Policy do
def to_form_error(%Ash.Error.Forbidden.Policy{} = e) do
{:forbidden, "Access denied due to security policy", []}
end
end
defimpl AshPhoenix.FormData.Error, for: Ash.Error.Forbidden.Policy do
def to_form_error(%Ash.Error.Forbidden.Policy{} = e) do
{:forbidden, "Access denied due to security policy", []}
end
end
Which I did not expect to remove.. this:
unknown actor

Policy | 🔎:

condition: always true

authorize if: actor is present | ✘ | 🔎

SAT Solver statement:

"actor is present" or "always false"
unknown actor

Policy | 🔎:

condition: always true

authorize if: actor is present | ✘ | 🔎

SAT Solver statement:

"actor is present" or "always false"
1 Reply
lawik
lawikOP•2mo ago
I assume this is what makes the error not bubble up from the changeset to the AshPhoenix.Form as well. Okay, adding this in the implementation helped:
Logger.warning("forbidden:\n\n#{Ash.Error.Forbidden.Policy.report(error, help_text?: false)}")
Logger.warning("forbidden:\n\n#{Ash.Error.Forbidden.Policy.report(error, help_text?: false)}")

Did you find this page helpful?