Skip to content

[BREAK]: when assigning tenants from bulk edit #15145

@faizanibneadil

Description

@faizanibneadil

Describe the Bug

the application is breaking when multi tenants plugin configured with hasMany: true like this

import { getUserTenantIDs } from "@/utilities/getUserTenantIDs"
import { multiTenantPlugin } from "@payloadcms/plugin-multi-tenant"
import type { Config } from "payload"

export const multiTenant = multiTenantPlugin<Config>({
    enabled:true,
    collections: {
        media: {},
        pages: {},
    },
    tenantField: {
        hasMany: true, // see this
        access: {
            read: () => true,
            update: ({ req }) => getUserTenantIDs(req.user).length > 0,
        },
    },
    tenantsArrayField: {
        includeDefaultField: false,
    },
    userHasAccessToAllTenants: (user) =>Boolean(user),
})

and when i editing docs in bulk ( assigning different tenants ) then app is crashing

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/issues

Reproduction Steps

  • create app with multi tenant example
  • and set hasMany flag to true
export const multiTenant = multiTenantPlugin<Config>({
    enabled:true,
    collections: {
        media: {},
        pages: {},
    },
    tenantField: {
        hasMany: true, // like this
        access: {
            read: () => true,
            update: ({ req }) => getUserTenantIDs(req.user).length > 0,
        },
    },
    tenantsArrayField: {
        includeDefaultField: false,
    },
    userHasAccessToAllTenants: (user) =>Boolean(user),
})
  • then create two tenants
  • then create minimum 2 docs in each tenant
  • then check/select ( in bulk edit ) any doc of any tenant
  • drawer will open
  • then select field assign tenant

app will crash

watch this video

Screen.Recording.2026-01-09.at.7.39.39.AM.mov

Which area(s) are affected?

plugin: multi-tenant

Environment Info

Binaries:
  Node: 22.19.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  payload: 3.70.0
  next: 16.1.1
  @payloadcms/db-postgres: 3.70.0
  @payloadcms/drizzle: 3.70.0
  @payloadcms/email-resend: 3.70.0
  @payloadcms/graphql: 3.70.0
  @payloadcms/live-preview: 3.70.0
  @payloadcms/live-preview-react: 3.70.0
  @payloadcms/next/utilities: 3.70.0
  @payloadcms/plugin-form-builder: 3.70.0
  @payloadcms/plugin-multi-tenant: 3.70.0
  @payloadcms/plugin-redirects: 3.70.0
  @payloadcms/plugin-search: 3.70.0
  @payloadcms/plugin-seo: 3.70.0
  @payloadcms/richtext-lexical: 3.70.0
  @payloadcms/sdk: 3.70.0
  @payloadcms/translations: 3.70.0
  @payloadcms/ui/shared: 3.70.0
  react: 19.2.3
  react-dom: 19.2.3
Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64
  Available memory (MB): 12288
  Available CPU cores: 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions