payloadcms / payloadcms/payload
Having non-existent fields in listSearchableFields fails in a bad way, only in production builds
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
Hi,
I stumbled upon this in a client project and then created a minimal setup to make sure it can be reproduced. I haven't dug into the code yet because this feels like it might be fixed very quickly by somebody who is familiar with it. Let me know if I should dive in myself instead.
When you create admin.listSearchableFields in a collection config and include a field that does not exist in the collection, you will not get any warnings and everything works fine when searching in the admin UI while working with pnpm dev.
Once you build the project with pnpm build and run it with pnpm start instead, the admin UI will “implode” without an error message when searching this collection.
In the server error messages, it will be reported with a pretty reasonable error message ("message": "The following path cannot be queried: foo")
I think this should already fail in pnpm dev and it should trigger the normal frontend error behavior in a production build.
I have not tested if this depends on using mongodb.
Link to the code that reproduces this issue
https://github.com/gerotakke/payload-listSearchableFields-reproduction
Reproduction Steps
- Check out the linked repository, run
pnpm build, thenpnpm start - Visit the admin UI and after setting up, visit the media collection
- Enter something in the search bar: 💣
After that, do the same thing with running pnpm dev instead — no errors.
This is the minimal change in the collection config to be able to trigger this error: https://github.com/gerotakke/payload-listSearchableFields-reproduction/commit/05339ee537045fd794ad4538dd4471cd3d923f33
Which area(s) are affected?
area: ui
Environment Info
Binaries:
Node: 22.21.1
npm: 10.9.4
Yarn: 1.22.22
pnpm: 10.20.0
Relevant Packages:
payload: 3.68.3
next: 15.4.9
@payloadcms/db-mongodb: 3.68.3
@payloadcms/graphql: 3.68.3
@payloadcms/next/utilities: 3.68.3
@payloadcms/richtext-lexical: 3.68.3
@payloadcms/translations: 3.68.3
@payloadcms/ui/shared: 3.68.3
react: 19.2.1
react-dom: 19.2.1
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:15 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T6041
Available memory (MB): 24576
Available CPU cores: 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked payload-listSearchableFields-reproduction repository and commit 05339ee, then run the listed pnpm build/start and pnpm dev reproduction steps. Trace the media collection search behavior and verify that an invalid listSearchableFields entry fails during development and uses the normal frontend error behavior in a production build.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, react, typescript
- Domain
- build-system, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100