ash-project / ash_paper_trail

The extension for keeping an audit log of changes to your Ash resources.
https://hexdocs.pm/ash_paper_trail
MIT License
28 stars 13 forks source link

Error with missing `changed?` in context with `bulk_update` #66

Open nallwhy opened 2 months ago

nallwhy commented 2 months ago

Describe the bug

Ash.bulk_update!(records, :update, %{field: value},
  strategy: [:stream, :atomic, :atomic_batches],
  return_errors?: true
)

** (KeyError) key :changed? not found in: %{private: %{authorize?: true}, bulk_update: %{index: 0}}

crashes on https://github.com/nallwhy/ash_paper_trail/blob/cc5f2c4385f9120ef570b552da505dfd7df941fa/lib/resource/changes/create_new_version.ex#L21

To Reproduce

https://github.com/nallwhy/ash_paper_trail/commit/fbebbeb4036bc4ee165365421b6a37f1c03e54f8

Expected behavior

no error

** Runtime

Additional context

nallwhy commented 2 months ago

changeset used in run_after_action_hooks/6 is came from index_changesets/2 that doesn't have changed? in it.

https://github.com/ash-project/ash/blob/078cc4f28b34897f2da36e898e4cb7e72b534381/lib/ash/actions/update/bulk.ex#L2089