Throwing error inside CollectionAfterChangeHook will end up creating duplicate items.

default discord avatar
KasparTr
8 months ago
1

I was doing post-update validation inside CollectionAfterChangeHook and throwing errors if something went wrong down the line (in another system which was called using APIs).



It worked well until I realized this one

very important non explicit consequence

of throwing errors inside CollectionAfterChangeHook.



⭕ After the error, when user hits SAVE again, a

new, duplicate,

object is created, not updated as it would be when no errors are throw.

  • default discord avatar
    Jarrod
    7 months ago

    @KasparTr if you have time please open an issue, this sounds like something that might need to be looked at and fixed in core?

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.