payloadcms / payloadcms/payload

BeforeChange hook error does not bubble up when re-ordering items

Open
#16,308 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: ui stale status: needs-triage
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

When having a collection with orderable: true and hooks that may throw an APIError(), the error from the hook does not bubble up when re-ordering the items. Instead the generic error "Failed to reorder. This can happen if you reorder several rows too quickly. Please try again." is shown.

My guess is that the ordering action is trying to save the document with payload, this runs through the hooks and if a hook throws, then the ordering action fails. Instead of the error of the hook being shown there is a fallback error that is displayed.

I would love to have the APIError that is thrown in the hook to bubble up and be displayed instead.

Link to the code that reproduces this issue

https://github.com/AlexRoosWork/re-ordering-items

Reproduction Steps

Create at least two entries in the Sample Collection.
Caution, there is a hook that throws 50% of the time, so you may need to try several times.

Try to re-order the items in the list view until the hook throws.

Which area(s) are affected?

area: ui

Environment Info
Binaries:
  Node: 24.14.1
  npm: 11.11.0
  Yarn: N/A
  pnpm: 10.28.0
Relevant Packages:
  payload: 3.83.0
  next: 16.2.3
  @payloadcms/db-mongodb: 3.83.0
  @payloadcms/graphql: 3.83.0
  @payloadcms/next/utilities: 3.83.0
  @payloadcms/richtext-lexical: 3.83.0
  @payloadcms/translations: 3.83.0
  @payloadcms/ui/shared: 3.83.0
  react: 19.2.4
  react-dom: 19.2.4
Operating System:
  Platform: linux
  Arch: x64
  Version: #1-NixOS SMP PREEMPT_DYNAMIC Thu Apr  2 11:09:54 UTC 2026
  Available memory (MB): 64022
  Available CPU cores: 20

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the linked reproduction and start with the admin list-view reordering flow for collections with orderable enabled. Trace how errors from the throwing hook are handled during reorder; done means the APIError from the hook is displayed instead of the generic reorder failure message.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.