Skip to content

Having non-existent fields in listSearchableFields fails in a bad way, only in production builds #14904

@gerotakke

Description

@gerotakke

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, then pnpm start
  • Visit the admin UI and after setting up, visit the media collection
  • Enter something in the search bar: 💣
Image

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: gerotakke/payload-listSearchableFields-reproduction@05339ee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugarea: uiRelated to the admin panel.status: needs-triagePossible bug which hasn't been reproduced yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions