Tenant not being recognised in load after upgrading to Ash 2.9.21
Hi, I'm trying to upgrade to the latest version of Ash (2.9.21) and my tests are failing after the upgrade.
In particular, I have code like this:
which previously worked, but now is giving an error of the form:
Basically I'm trying to load a calculation on a resource that has a related parent - and now it's not picking the tenant up. The API of the load function seems the same after the version bump - Any ideas what has changed here?
22 Replies
random but can you try setting the tenant with
Ash.set_tenant/1
beforehand?@kernel thanks for the suggestion!
If I call
Ash.set_tenant(t)
at the start of the test I get the following:
🙀
crazy, I didn't actually think you would need to add tenant as an opt for the load to begin with (as your record should have the tenant set in the metadata field)
@Zach Daniel could this be a bug?
an engine deadlock is 100% a bug
What version did you upgrade from?
2.6.21
oh damn
😆
it looks like the tenant id is not being passed from a child to parent in a query for a calculation...? could this be causing a bug, that then manifests in the deadlock?
Okay, so when you say it has a related parent, do you mean the calculation depends on the parent record?
yeah, that is the likely cause
I'm thinking it should be a relatively simple change to get the tenant where it needs to be here
yes - the calculation in the child depends on the parent.
it has the following code at the top of the calculation:
can you try main?
actually...I'm still not 100% sure. That might fix it, lemme konw
@Zach Daniel it didn't fix it - still getting the TenantRequired error
Okay, thought that might happen
is there a stacktrace?
okay, pushed something up again that might do it
if this doesn't work then we're going to need to get a test reproduction in ash
no, I'm getting the same error unfortunately
damn. Okay, so the best way for me to fix this would be a test file that defines two multitenant resources and has a similar calculation.
I’ll try and sort one for you tomorrow morning and stick it in a pull request if that would help?
That would help immensely 🙂
Got a lot of plates spinning at the moment, that will make things much easier
@Zach Daniel
https://github.com/ash-project/ash/pull/606
GitHub
added failing test showing that calculations cannot access attribut...
… of parent in multitenant context due to bug causing tenant id not being present
Contributor checklist
added failing test for minimal reproduction of bug
relates to issue #605
Sorry it's a bit messy and brief - I had very little time this morning so put it together in a rush
I edited one of the test files relating to calculations, adding a failing test fro accessing a calculation on a parent from a child, in a multitenant context
Beautiful, thanks!