Skip to content

Commit a439ac4

Browse files
committed
Add error for wrong record passed in to handle_changes
1 parent 932bae7 commit a439ac4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/upload/multi.ex

+7-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,15 @@ defmodule Upload.Multi do
8989
# This code is run after the record in inserted in the Multi pipeline.
9090
# We can use the record ID here to upload the photo.
9191
record = Map.get(changes, subject)
92+
93+
if is_nil(record) do
94+
raise ArgumentError,
95+
"The key '#{subject}' is not in the multi changes: #{inspect(changes)}"
96+
end
97+
9298
record = repo.preload(record, fields)
9399

94-
changeset = Ecto.Changeset.cast(record, changeset.params, [])
100+
changeset = Ecto.Changeset.cast(record, changeset.params || %{}, [])
95101

96102
changeset =
97103
fields

0 commit comments

Comments
 (0)