payloadcms/payload · error · Error

No auth config found for collection: ${collection}

Error message

No auth config found for collection: ${collection}

What it means

After authenticating, `refresh` reads `result.user.collection` and looks up `payload.collections[collection]?.config.auth`. If the resolved collection has no `auth` config (or the slug is absent from the registry), it throws. The session references a collection that is not auth-enabled in the running config.

Source

Thrown at packages/payload/src/auth/serverFunctions/refresh.ts:46

  if (!result.user) {
    throw new Error('Cannot refresh token: user not authenticated')
  }

  const existingCookie = await getExistingAuthToken({
    cookiePrefix: payload.config.cookiePrefix,
    serverAdapter,
  })

  if (!existingCookie) {
    return { message: 'No valid token found to refresh', success: false }
  }

  const collection: CollectionSlug | undefined = result.user.collection
  const collectionConfig = payload.collections[collection]

  if (!collectionConfig?.config.auth) {
    throw new Error(`No auth config found for collection: ${collection}`)
  }

  const req = await createLocalReq({ user: result.user }, payload)

  const refreshResult = await refreshOperation({
    collection: collectionConfig,
    req,
  })

  if (!refreshResult) {
    return { message: 'Token refresh failed', success: false }
  }

  await setAuthCookie({
    authConfig: collectionConfig.config.auth,
    cookiePrefix: payload.config.cookiePrefix,
    serverAdapter,
    token: refreshResult.refreshedToken,

View on GitHub (pinned to 00c58b35c0)

Solutions

  1. Confirm the user's `collection` resolves to an existing, auth-enabled collection slug.
  2. If slugs changed, invalidate old tokens and re-seed users under the new slug.
  3. Ensure `getPayload` finished initializing before `refresh` runs.

Example fix

// config drift: collection 'users' renamed to 'members'
// before — token still carries collection: 'users'
// after — migrate users to 'members' (auth: true) and clear stale auth cookies
export const Members = { slug: 'members', auth: true, fields: [...] }
Defensive patterns

Strategy: validation

Validate before calling

function collectionHasAuth(payload, slug) {
  return !!payload.collections[slug]?.config?.auth
}
// before refresh, ensure the user's collection resolves:
if (!collectionHasAuth(payload, result.user.collection)) await clearAuthCookieAndRedirect()

Type guard

function isAuthCollection(payload, slug): slug is AuthCollectionSlug {
  return !!payload.collections[slug]?.config?.auth
}

Try / catch

try {
  await refresh({ config, serverAdapter })
} catch (e) {
  if (e instanceof Error && /No auth config found/.test(e.message)) {
    await clearAuthCookieAndRedirect()
  } else throw e
}

Prevention

When it happens

Trigger: A token whose `collection` claim points to a slug that no longer exists, was renamed, or was never configured with `auth: true`. The lookup `payload.collections[collection]?.config.auth` resolves to undefined.

Common situations: Collection slug renamed in config while existing tokens still carry the old slug; the collection's `auth` was removed; a custom/legacy token minted with a wrong `collection`; payload not fully initialized at call time.

Related errors


AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12). Data as JSON: /api/errors/44628f7260becb8c. Report an issue: GitHub.