AshGraphql unknown error
The code for the action is this
I made the
relation
change, which is just calling manage_relationship, nothing more51 Replies
The rest of the error message is here
discord did not allow to send a very long message
Ash.Notifier.notify has a line like this
resource notifications came as
:ok
but I don't have deep enough understanding of ash internal, to know where is it coming from
But this test passes
@Vahagn can you update to latest ash and provide an updated stack trace? (and make sure the issue is stil there)
ok
same error
What is this?
Is that your own thing?
yes, just a change that passes parameters to manage_relationship
Does this issue happen without them?
So without any change to relationships?
yes
it did not, but it also did not change anything
🤔 Sorry, not following
without those, the error did or did not happen?
this is it
without those it worked without errors
what happens if you remove the
atomic/3
implementationsame error
what type of relationship is
:member
?I am guessing from this
(ash 3.5.21) lib/ash/actions/update/bulk.ex:137: Ash.Actions.Update.Bulk.run/6
that graphql runs it with bulk
belongs_to
But in my test I use just regular updatecan you confirm if its specifically one of those that is causing the issue?
and it works
when I removed accepted_doctor, it worked
Okay, so what makes
accepted_doctor
different from the member
?First step is likely to update your test to use bulk updates
how do I tell it I don't need atomic updates?
require_atomic? false
I have this
Add
strategy: [:stream]
to your bulk update optionsNow the test passes with bulk too
Add
notify?: true
option as wellwhere should I add the options?
to bulk_update
yep
this works
I don't know what it does
but it does not crash
😆 it should effectively do the same thing as what the single update does
Do you see that in the SQL logs?
is there a way to enable sql logs in tests?
Logger.configure(level: :debug)
at the top of the testYeah, I see it inserting then updating back the inserted ID
I have a guess
I don't pass the tenant
But I pass entity_id
which is my attribute to know who the tenant is
Can there be an issue with that?
Anyone has an idea what can be the issue of this? How can I better debug it?
This is the stack of the caller who puts
:ok
, so when notifier tries to notify, it gets that and calls .resource on itThe best thing to do here would be to get it reproduced
I'll fix ASAP as soon as we can reproduce the issue
Alternatively, you can clone down ash core locally, point your codebase at it, and then throw some IO.inspect at the problem area to see what is happening
That is how I got this stacktrace
Oh, sorry I thought it was the same one
So we need to find out where that
:ok
is coming from
Likely from calls to ManagedRelationship
in that module
That would be the first place to lookWill try to find a test case that fails
I'd throw some inspects around the falls in bulk update to manage relationships
If I can get enough info to fix that will work too 🙂
the problem is that every time I put an inspect, I have to compile every dependency :))), so it takes some time to dig around
If I find any helpful info or strange values, will report them here
Can it be an issue of me using OTP 28?
Could be 🙂
OTP 28 is not supported by any current Elixir version AFAIK
I had the same error yesterday on my other laptop, with OTP 27, so I don't think that is the issue
and it was exactly the same error
👍
The main issue is that the problem isn't where the stacktrace is
its somewhere ahead of it that is somehow getting
:ok
for notificationsI have reproduced :))))))
The problem with my test was that when I was creating the invitation, I was giving it back to the bulk_update
and it contained a tenant in the changeset
so I changed my test to Ash.read!() and pass it to bulk_update, which removed the tenant that I specified in the context earlier
this is the new test
I just added the same opt's from graphql code
I don't know which of them is neccessary
Nice 👍
Next step is making it so I can reproduce it 😆
:))))
if I specify a multitenancy block in a resource, and not provide a tenant in context, but provide the attribute, will it work?
I am guessing that is the problem here
Interesting 🤔
I don't see why that would be related
but no, that shouldn't work
Unless you've set
global? true
ohhh
can I set global? true in manage_relationship?
No, but you can bypass multitenancy in the individual actions
so inside action I can set global? true
?
Hmm...actually it looks like we only support doing that for read actions at the moment 😢
https://hexdocs.pm/ash/dsl-ash-resource.html#actions-read-multitenancy
that option hasn't been added to the other action types
My suggestion: swap out your manage relationships with calls to create the other resources
How should I create?
just manually create and manually update the original one in after_action?
Solution
You can create in a
before_action
hook and use that to update the recordThanks a lot, it worked