Nested flows steps possibly returns differently if using `apply` ?
Sorry if I bother you again on flow issues. This step:
Correctly returns
{:ok, result}
with updated status on resource_record
While this:
returns {:ok, nil}
even if there is no error and the resource_record is updated with the right status17 Replies
When you say it returns
{:ok, nil}
what do you mean?
Do you mean the result of apply(input.resource, transitioned_status_name, [resource_record])
returns {:ok, nil}
Or that that returns the right value, but somehow the custom step returns something else?it returns the right value but somehow the custom step returns
nil
as the ash flow result result🤔
can I see the flow where you call the step?
yep
🤔 what happens if you do
returns :create_data_in_and_map_resources
I have this test:
and
generated_product
is nil
and this test:
and quantity
is nil
yes
same result
🤔 okay, could you construct a flow with the same structure, but with simple custom steps?
Ideally something I could test against
I will try to make a test directly in Ash and make a PR
Let me know if this is a good test: https://github.com/ash-project/ash/pull/552
GitHub
tests for custom steps returning nil even when there is a right res...
Tests to debug this situation:
https://discord.com/channels/711271361523351632/1092520117977489418/1092520117977489418
tests are failing while they should pass.
Looks awesome thanks!
Okay, so I've fixed some issues that I found, but the actual primary issue is that you can't use
return
with a single step inside of a map
You'd need to set the output
step of the map (which defaults to the last step so not entirely necessary in your case)
What I ended up doing after merging your tests:
That way it returns either the created or updated user
So I need to write a validator for step returns
Pushed, main
has a verifier that will error if a return is invalidthanks Zach
So if I have a
map
of 10 elements and inside I have only a create
step what will it return by default: the last created element or all the 10 created elements?It will return the results of the last step of the map in a list
It seems that if I add the
custom :return_value
the flow returns Ash.Flow.Result{result: {:ok, actual_result}}
instead of Ash.Flow.Result{result: actual_result}
I need to change your code to this:
To make the tests pass, is it correct?hm.... I don't think so.
is your custom creation_bulk or update_bulk returning
{:ok, {:ok, ...}}
or something like that? I think that is what that means.ok will double check that
@Zach Daniel you were obviously right 🙂