Problem in using manage_relationship and Ash events with tenant
Hi, this is my update action, that i use for normal user which has tenant and site_id
so when i want to do for the user which is master (and no site_id) i do like this
as you see i call the normal update action with
tenant and it works. but when i use the ash events and add update action inside the only_actions it returns this warning πππ2 Replies
Warning
when i delete the update from
It works and no problem!! how can i fix this?
By the way if i delete the
tag_ids manage_relationship and even the update exists in only_actions it works without problem!
And i have set the tenant why still it is finding the tenant when Ash events is set π₯² without it, it consider the tenant but with ash events i think it clear the tenant that i set
Full warning: https://gist.github.com/shahryarjb/d990e59d59222a6b649b77faadd313b5
Thank you in advance
I even today put some print inside ash_events/lib/events/update_action_wrapper.ex, but it has tenant that i set and has no problem, but i do not know why it can not pass the tenant when Ash event is enabled for update action!
for example i have many to many
Blog post -> okey
Tag -> return tenant nil (without Ash event this knows the tenant we set inside Blog post)
Blog Tag -> before Tag can not know about tenant that we set in Blog post so do not anything
Hi @Zach ,
Iβm really sorry for tagging you π I know youβre quite busy. I was wondering if you could give me a bit of guidance on where I should look to track down this issue. Iβve tested the entire Ash Events library but havenβt been able to find where the problem might be. It might be something I can help fix if I can locate it. Thank you in advance
I found an easy way
inside ash source ash/lib/ash/actions/managed_relationships.ex
inside load and the relationships we change the tenant = engine_opts[:tenant] to this
and it fixes the problem! i did not send the PR, because other places maybe the creator of this problem! (that i could not be able to find)
But i think it is safe place because it is the last place it excitable, and my 4k tests and ash tests passed and it works!
I think cause of this problem because ash update is like manual update not the relation like, so it dose not consider the changeset tenantIf you are good i can send it as PR Thank you @Zach
Solution
Please do!