payloadcms / payloadcms/payload

Polymorphic Join field is broken

Open
#13,777 5 comments 8 reactions 1 assignee View on GitHub

@r1tsuu is already working on this.

Since Jan 15, 2026.

Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

According to the documentation, we should be able to create a polymorphic join field like for example:

export const People: CollectionConfig = {
  slug: 'people',
  fields: [
    {
      name: 'name',
      type: 'text',
      required: true,
    },
    {
      name: 'roles',
      type: 'join',
      collection: ['staff-roles', 'student-roles'],
      on: 'person',
    },
  ],
}

When opening the edit page of the People collection in the Admin, we:

  1. Get an error in the server console
  2. The edit page loads, but the join field is not rendered completely. No joined rows are shown.

The issue happens on as early as 3.43, but also on 3.55.1 and main.

This is the error we get in the console:

[16:08:10] ERROR: There was an error building form state
    err: {
      "type": "TypeError",
      "message": "Cannot read properties of undefined (reading 'admin')",
      "stack":
          TypeError: Cannot read properties of undefined (reading 'admin')
              at getColumns (/home/robin/code/payload/.next/server/chunks/ssr/packages_ui_src_e487b3c2._.js:5190:465)
              at buildTableState (/home/robin/code/payload/.next/server/chunks/ssr/packages_ui_src_e487b3c2._.js:6074:181)
              at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
              at async buildTableStateHandler (/home/robin/code/payload/.next/server/chunks/ssr/packages_ui_src_e487b3c2._.js:5938:21)
              at async executeActionAndPrepareForRender (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.dev.js:33:4432)
              at async /home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.dev.js:33:2264
              at async handleAction (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.dev.js:32:23711)
              at async renderToHTMLOrFlightImpl (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.dev.js:38:30115)
              at async doRender (/home/robin/code/payload/.next/server/chunks/ssr/905b1_next_dist_650a1e83._.js:2520:28)
              at async AppPageRouteModule.handleResponse (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.dev.js:40:57864)
              at async handleResponse (/home/robin/code/payload/.next/server/chunks/ssr/905b1_next_dist_650a1e83._.js:2666:32)
              at async handler (/home/robin/code/payload/.next/server/chunks/ssr/905b1_next_dist_650a1e83._.js:3043:20)
              at async doRender (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/base-server.js:1586:34)
              at async DevServer.renderToResponseWithComponentsImpl (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/base-server.js:1928:13)
              at async DevServer.renderPageComponent (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/base-server.js:2394:24)
              at async DevServer.renderToResponseImpl (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/base-server.js:2434:32)
              at async DevServer.pipeImpl (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/base-server.js:1034:25)
              at async NextNodeServer.handleCatchallRenderRequest (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/next-server.js:393:17)
              at async DevServer.handleRequestImpl (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/base-server.js:925:17)
              at async /home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/dev/next-dev-server.js:398:20
              at async Span.traceAsyncFn (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/trace/trace.js:157:20)
              at async DevServer.handleRequest (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/dev/next-dev-server.js:394:24)
              at async invokeRender (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/lib/router-server.js:239:21)
              at async handleRequest (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/lib/router-server.js:436:24)
              at async NextCustomServer.requestHandlerImpl (/home/robin/code/payload/node_modules/.pnpm/next@15.4.4_@opentelemetry+api@1.9.0_@playwright+test@1.54.1_babel-plugin-macros@3.1.0_babel-_nh6e7yzpetogfn6s3qd7kk6wqu/node_modules/next/dist/server/lib/router-server.js:464:13)
              at async Server.<anonymous> (file:///home/robin/code/payload/test/dev.ts:1:2992)
    }

The response we get in the API works, except the roles field will also be empty.

I initially came across this issue when using Postgres, but the issue also exists when using Mongo as reproduced in the linked repository.

Link to the code that reproduces this issue

https://github.com/RobinvdGriend/payload/tree/issue/polymorphic-join

Reproduction Steps

This issue has been reproduced following ISSUE_GUIDE.md. After cloning the repository, install the packages:

pnpm install

The code to reproduce the issue can be found under test/_community. To start the dev server run:

pnpm dev _community --start-memory-db

Navigate to (http://localhost:3000/admin/collections/people). You should see a single item in the index. Click this item to go to its edit page, this reproduces the issue. You see the roles field remains empty and an error is reported in the server console. Verify that indeed this person has roles by navigating to the 'Staff Roles' and 'Student Roles' collections.

Which area(s) are affected? (Select all that apply)

area: core

Environment Info
Binaries:
  Node: 22.16.0
  npm: 11.4.2
  Yarn: N/A
  pnpm: 10.15.1
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu, 28 Aug 2025 19:49:53 +0000
  Available memory (MB): 15352
  Available CPU cores: 6

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.