Policy breakdowns for fields

Is it possible to get a policy breakdown for an Ash.ForbiddenField in a record returned by a read action?
Solution:
I think they can be logged with log_policy_breakdowns but not retrieved from a forbidden field.
Jump to solution
12 Replies
allenwyma
allenwyma•2w ago
did you try to turrn on the policy breakdown? i think it may work.
aidalgol
aidalgolOP•2w ago
I have that on already, and I get breakdowns for actions, but I just have a value #Ash.ForbiddenField<field: foo, type: :attribute, ...> if I try accessing the field that's forbidden.
allenwyma
allenwyma•2w ago
oh: a field policy? not sure about that one, maybe a setting to show that.
ken-kost
ken-kost•2w ago
AFAIS it's not supported but I think it could be. 🤔 Zach will know best. for instance Ash.Error.Forbidden.Policy has functions exception, message, report; while Ash.Error.Forbidden.ForbiddenField only has message
Solution
ZachDaniel
ZachDaniel•2w ago
I think they can be logged with log_policy_breakdowns but not retrieved from a forbidden field.
aidalgol
aidalgolOP•2w ago
I added config :ash, :policies, log_policy_breakdowns: true to my config.exs file and reran the test that gets me the forbidden field, but I'm not seeing any new logging.
ZachDaniel
ZachDaniel•2w ago
log_policy_breakdowns takes a log level
aidalgol
aidalgolOP•2w ago
Hmm, I've changed that to config :ash, :policies, log_policy_breakdowns: :warning, and still no logging.
ZachDaniel
ZachDaniel•2w ago
try log_successful_policy_breakdowns: :warning
ZachDaniel
ZachDaniel•2w ago
😢 Can you open an issue, ideally w/ a reproduction
aidalgol
aidalgolOP•2w ago
GitHub
Policy breakdown logging throws an error · Issue #2024 · ash-proj...
Describe the bug Setting the config option log_successful_policy_breakdowns causes Ash to throw an error instead of logging a forbidden field. To Reproduce Application.put_env(:ash, :validate_domai...

Did you find this page helpful?