{"record":{"id":"44628f7260becb8c","repo":"payloadcms/payload","slug":"no-auth-config-found-for-collection-collection-44628f","errorCode":null,"errorMessage":"No auth config found for collection: ${collection}","messagePattern":"No auth config found for collection: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/payload/src/auth/serverFunctions/refresh.ts","lineNumber":46,"sourceCode":"\n  if (!result.user) {\n    throw new Error('Cannot refresh token: user not authenticated')\n  }\n\n  const existingCookie = await getExistingAuthToken({\n    cookiePrefix: payload.config.cookiePrefix,\n    serverAdapter,\n  })\n\n  if (!existingCookie) {\n    return { message: 'No valid token found to refresh', success: false }\n  }\n\n  const collection: CollectionSlug | undefined = result.user.collection\n  const collectionConfig = payload.collections[collection]\n\n  if (!collectionConfig?.config.auth) {\n    throw new Error(`No auth config found for collection: ${collection}`)\n  }\n\n  const req = await createLocalReq({ user: result.user }, payload)\n\n  const refreshResult = await refreshOperation({\n    collection: collectionConfig,\n    req,\n  })\n\n  if (!refreshResult) {\n    return { message: 'Token refresh failed', success: false }\n  }\n\n  await setAuthCookie({\n    authConfig: collectionConfig.config.auth,\n    cookiePrefix: payload.config.cookiePrefix,\n    serverAdapter,\n    token: refreshResult.refreshedToken,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/auth/serverFunctions/refresh.ts#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the user's `collection` resolves to an existing, auth-enabled collection slug.","If slugs changed, invalidate old tokens and re-seed users under the new slug.","Ensure `getPayload` finished initializing before `refresh` runs."],"exampleFix":"// config drift: collection 'users' renamed to 'members'\n// before — token still carries collection: 'users'\n// after — migrate users to 'members' (auth: true) and clear stale auth cookies\nexport const Members = { slug: 'members', auth: true, fields: [...] }","handlingStrategy":"validation","validationCode":"function collectionHasAuth(payload, slug) {\n  return !!payload.collections[slug]?.config?.auth\n}\n// before refresh, ensure the user's collection resolves:\nif (!collectionHasAuth(payload, result.user.collection)) await clearAuthCookieAndRedirect()","typeGuard":"function isAuthCollection(payload, slug): slug is AuthCollectionSlug {\n  return !!payload.collections[slug]?.config?.auth\n}","tryCatchPattern":"try {\n  await refresh({ config, serverAdapter })\n} catch (e) {\n  if (e instanceof Error && /No auth config found/.test(e.message)) {\n    await clearAuthCookieAndRedirect()\n  } else throw e\n}","preventionTips":["Keep collection slugs stable; if renamed, migrate tokens and clear stale cookies.","Validate `user.collection` resolves to an auth-enabled collection before refresh."],"tags":["auth","config","session","token"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}