You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[plugin-multi-tenant] Infinite redirect loop with custom tenantFieldName and isGlobal collections #18690
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.
Activity