Bulk create action Changeset Error
I'm using bulk create action with upsert and I'm tryong to test that not valid resources will not be created.
Using this code with a purposedly wrong changeset gives me this error:
I would expect errors to be "nilled"
28 Replies
This is the full error stacktrace:
Not sure what's going on here . maybe
elixir elixir
upsert_identity: :unique_esolver_id,
``
:unique_esolver_id should be
unique_resolver_id`Thanks @edwinofdawn edwin, the problem is that the
InvoiceData
resource needs a customer_id
but I would expect that I can manage those errors in the stream without destroying the bulk action.@core-team spotted this out but I don't know if I'm right or if it is connected with my error:
https://github.com/ash-project/ash/blob/13f834ad09d42fa183095cb8cfd90bb2c7853181/lib/ash/actions/create/bulk.ex#L557
shouldn't it be:
throw({:error, Ash.Error.to_error_class(changeset.errors), 0, []})
that is to say changeset.errors
instead of changeset.error
?GitHub
ash/bulk.ex at 13f834ad09d42fa183095cb8cfd90bb2c7853181 · ash-proje...
A declarative and extensible framework for building Elixir applications. - ash/bulk.ex at 13f834ad09d42fa183095cb8cfd90bb2c7853181 · ash-project/ash
Also this condition https://github.com/ash-project/ash/blob/13f834ad09d42fa183095cb8cfd90bb2c7853181/lib/ash/actions/create/bulk.ex#LL556C11-L556C11
if opts[:stop_on_error?] && !opts[:return_stream?] do
as stop_on_error?
is false by default means that it will always throw if return_stream?
is true is this the wanted behavior? Or am I missing something?GitHub
ash/bulk.ex at 13f834ad09d42fa183095cb8cfd90bb2c7853181 · ash-proje...
A declarative and extensible framework for building Elixir applications. - ash/bulk.ex at 13f834ad09d42fa183095cb8cfd90bb2c7853181 · ash-project/ash
👋 thanks for all the details! There are a few issues w/ errors during bulk actions that have been on my list to resolve, let me take a look at what you've provided so far.
you're very welcome bulk actions with upsert are cooooooool and I managed to simplify data import a lot with this new feature. Thanks a lot!
When you mentioned that you provided invalid changesets on purpose, can you show me what you mean?
this is the create action
I send a nil
customer_id
but you're sending a map in, not a changeset right?
a list of maps with customer_id key set to nil
okay, this should be fixed 🙂
in the latest versions of ash and ash_postgres
unfortunately I keep having the same error 😓
Huh.
Okay, will look further today.
Yeah, I guess your error does actually look different from the errors that other people have been facing
@tommasop#2001 can you provide an updated stack traces with the new versions?
Of course:
here it is
let me know if I can help you
thank you 😄
I'm working on a reproduction, will let you know if I have any other questions. Appreciate all the information 🙂
okay this is interesting
so I did essentially the same exact thing you did
leaving a required attribute as
nil
well, there are two issues.
1. it let me do that and I got a postgres error instead of a changeset error
2. it didn't get me the error that you have
the top of the stacktrace would be better than the bottom in this case 😄
i.e whatever is here: .....
okay I think I found it
don't have the issue reproduced yet though
but found some suspicious code 🙂
okay, try main
of ash
🙂still seeing the same error will post it here
and just to confirm you definitely updated both ash and ash_postgres to the latest
main
using mix deps.update ash ash_postgres
?only updated ash not ash_postgres
sssssorry
that probably won't fix it
so thats no problem
updating ash was likely enough
but lets just be sure and update ash_postgres too 😄
strange that there is no
ash
line/line number in that stacktrace you sent just now
oh, there hasn't been this whole time
I was using the wrong number when investigatingconfirmed updating also ash_postgres doesn't solve the problem
So the only real lead we have is:
in Ash.Actions.Create.Bulk.do_run/5
there is no line number that you can see that points at a line in an ash file?no, the first one is that in ash_engine 789
found it
okay, try main of
ash
🙂WOHOOO solved thanks!
🥳
thanks for bearing with me 😆
no thank YOU for bearing with my specific problem really appreciate your support
My pleasure 🙂