Skip to content

Setting upload.safeFileNames to a RegExp causes runtime error #15740

@Shayan-To

Description

@Shayan-To

Describe the Bug

I have set upload.safeFileNames to a RegExp object in payload.config.ts, and when trying to open /admin in the browser, a runtime error occurs:

 ⨯ Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
  {safeFileNames: RegExp, adapters: []}
                  ^^^^^^
    at stringify (<anonymous>) {
  digest: '2619984431'
}

Link to the code that reproduces this issue

https://github.com/Shayan-To/payload-repro/tree/repro-1

Reproduction Steps

Checkout the project in branch repro-1. Start the dev server (pnpm run dev). Go to /admin in the browser. See the error.

Which area(s) are affected?

area: core

Environment Info

Binaries:
  Node: 24.11.1
  npm: 8.19.4
  Yarn: 4.12.0
  pnpm: 10.28.2
Relevant Packages:
  payload: 3.77.0
  next: 15.4.11
  @payloadcms/db-sqlite: 3.77.0
  @payloadcms/drizzle: 3.77.0
  @payloadcms/graphql: 3.77.0
  @payloadcms/next/utilities: 3.77.0
  @payloadcms/richtext-lexical: 3.77.0
  @payloadcms/translations: 3.77.0
  @payloadcms/ui/shared: 3.77.0
  react: 19.2.1
  react-dom: 19.2.1
Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 65421
  Available CPU cores: 4

Metadata

Metadata

Assignees

Labels

area: coreCore Payload functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions