Skip to content

[plugin-multi-tenant] Infinite redirect loop with custom tenantFieldName and isGlobal collections #18690

Open

Description

@GSFranzoni

Describe the Bug

When using @payloadcms/plugin-multi-tenant@3.90.2 with a custom tenantFieldName (e.g. organization), navigating to an isGlobal: true collection without selecting a tenant can trigger an infinite redirect loop if the selected tenant has no singleton document yet.

The getGlobalViewRedirect helper correctly uses the configured tenant field when looking up an existing document, but hardcodes tenant when creating a missing autosaved draft:

data: { tenant: tenantID }

As a result, the newly created document is not associated through the configured organization field. Subsequent requests cannot find it, so the helper repeatedly creates new drafts and redirects to their IDs.

In my local environment, this produced 555 orphaned draft documents with no organization assigned.

Expected behavior: The helper should create one draft associated with the resolved tenant, redirect to it, and reuse the same document on subsequent requests.

Suggested fix: Pass tenantFieldName to the draft creation helper and use:

data: { [tenantFieldName]: tenantID }

The issue is reproducible with a custom tenant field and a tenant-scoped singleton collection that has drafts/autosave enabled.

Link to the code that reproduces this issue

https://github.com/GSFranzoni/payloadcms-plugin-multi-tenant-custom-field-global-redirect-loop

Reproduction Steps

  1. Clone the linked minimal reproduction and install dependencies:

    bun install
  2. Configure .env to use SQLite and set a Payload secret:

    DATABASE_URL=file:./payload.db
    PAYLOAD_SECRET=local-development-secret
  3. Seed the database:

    bun run seed
  4. Start the app:

    bun run dev -- --port 3001
  5. Open http://localhost:3001/admin and log in with admin@example.com / TestPassword123!.

  6. Leave the tenant filter empty and open Navigation Content.

  7. Observe repeated redirects to /admin/collections/navigation-content/<id> with increasing IDs. Each redirect creates another draft document.

Which area(s) are affected?

plugin: multi-tenant

Environment Info

Binaries:
  Node: 24.21.0
  Node: 1.4.0
  npm: 11.19.0
  Yarn: 4.18.1
  pnpm: 12.11.2
Relevant Packages:
  payload: 3.90.2
  next: 16.3.3
  @payloadcms/db-sqlite: 3.90.2
  @payloadcms/drizzle: 3.90.2
  @payloadcms/graphql: 3.90.2
  @payloadcms/next/utilities: 3.90.2
  @payloadcms/plugin-multi-tenant: 3.90.2
  @payloadcms/richtext-lexical: 3.90.2
  @payloadcms/translations: 3.90.2
  @payloadcms/ui/shared: 3.90.2
  react: 19.2.6
  react-dom: 19.2.6
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Tue Nov 5 00:21:55 UTC 2024
  Available memory (MB): 15965
  Available CPU cores: 6

Activity

  1. added
    status: needs-triagePossible bug which hasn't been reproduced yet
    validate-reproductionAuto-added tag on create to tell bot to check recreation URL, removed after check.
    on Oct 13, 2026
  2. added and removed
    validate-reproductionAuto-added tag on create to tell bot to check recreation URL, removed after check.
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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