How can I add the flow actor as the actor of one of the steps?

This is my flow:
defmodule MyFlow do
alias Marketplace.Markets.Property.Offer

use Ash.Flow

flow do
api Marketplace.Markets

argument :property_id, :uuid, allow_nil?: false

returns :make_own_offers_old

steps do
read :make_own_offers_old, Offer, :make_own_offers_old do
not_found_error? false

input %{property_id: arg(:property_id)}
end
end
end
end
defmodule MyFlow do
alias Marketplace.Markets.Property.Offer

use Ash.Flow

flow do
api Marketplace.Markets

argument :property_id, :uuid, allow_nil?: false

returns :make_own_offers_old

steps do
read :make_own_offers_old, Offer, :make_own_offers_old do
not_found_error? false

input %{property_id: arg(:property_id)}
end
end
end
end
The :make_own_offers_old read action expects to receive an actor. If I run my flow like this: MyFlow.run!("0cbf2651-2644-44d9-9a06-9a6076b5630c", actor: user) It will return this error:
** (Ash.Error.Invalid) Input Invalid

* actor is required
at make_own_offers_old
** (Ash.Error.Invalid) Input Invalid

* actor is required
at make_own_offers_old
Because make_own_offer_old is not receiving the actor
12 Replies
ZachDaniel
ZachDaniel•3y ago
šŸ¤” Try:
MyFlow.run!("0cbf2651-2644-44d9-9a06-9a6076b5630c", %{}, actor: user)
MyFlow.run!("0cbf2651-2644-44d9-9a06-9a6076b5630c", %{}, actor: user)
Blibs
BlibsOP•3y ago
Same issue
ZachDaniel
ZachDaniel•3y ago
This may be a bug actually šŸ¤” Do you have require_actor? true in your api?
Blibs
BlibsOP•3y ago
I don't
ZachDaniel
ZachDaniel•3y ago
Trying to think of the best way to pinpoint the error So strange remove that read step and add a custom step
custom :example, fn _, context ->
IO.inspect(context[:actor)
{:ok, nil}
end
custom :example, fn _, context ->
IO.inspect(context[:actor)
{:ok, nil}
end
Can you tell me what that gives you?
Blibs
BlibsOP•3y ago
It gives nil I'm using Ash 2.6.3, want me to upgrade to 2.6.5 and try again?
ZachDaniel
ZachDaniel•3y ago
can't hurt šŸ™‚ but thats probably not the issue
Blibs
BlibsOP•3y ago
Well, I just updated, but I'm getting nil too
ZachDaniel
ZachDaniel•3y ago
can you try main?
Blibs
BlibsOP•3y ago
All right! Working fine in main
ZachDaniel
ZachDaniel•3y ago
noice will release that now then
Blibs
BlibsOP•3y ago
Thanks!

Did you find this page helpful?