payloadcms/payload · error · Error
No auth config found for collection: ${collection}
Error message
No auth config found for collection: ${collection} What it means
Thrown in the server-function `login` when `payload.collections[collection]?.config.auth` is falsy. Either the collection slug does not exist on the resolved Payload instance, or it exists but is not an auth-enabled collection. This is a plain `Error` (not an `APIError`), so it has no HTTP status — it surfaces wherever the adapter calls `login()`.
Source
Thrown at packages/payload/src/auth/serverFunctions/login.ts:48
/**
* Logs a user in and writes the auth cookie through the supplied `serverAdapter`,
* so the function is framework-agnostic; each adapter binds its own.
*/
export async function login<TSlug extends AuthCollectionSlug>({
collection,
config,
email,
password,
serverAdapter,
username,
}: LoginArgs<TSlug>): Promise<LoginResult<TSlug>> {
const payload = await getPayload({ config, cron: true })
const authConfig = payload.collections[collection]?.config.auth
if (!authConfig) {
throw new Error(`No auth config found for collection: ${collection}`)
}
const loginWithUsername = authConfig.loginWithUsername ?? false
if (loginWithUsername) {
if (loginWithUsername.allowEmailLogin) {
if (!email && !username) {
throw new Error('Email or username is required.')
}
} else {
if (!username) {
throw new Error('Username is required.')
}
}
} else {
if (!email) {
throw new Error('Email is required.')
}View on GitHub (pinned to 00c58b35c0)
Solutions
- Confirm the slug exists in `config.collections` and the collection is declared with `auth: true` (or `auth: {...}`).
- Use the typed `AuthCollectionSlug` to catch slug typos at compile time.
- Ensure `getPayload({ config })` receives the same config that defines the collection.
- After adding/renaming a collection, rebuild and restart so the slug resolves.
Example fix
// before
await login({ collection: 'admins', config, password, email, serverAdapter })
// after — verify the slug is a registered auth collection
if (!payload.collections['users']?.config.auth) {
throw new Error('Configuration error: users collection is not auth-enabled')
}
await login({ collection: 'users', config, password, email, serverAdapter }) Defensive patterns
Strategy: validation
Validate before calling
// Verify the collection is a registered auth collection before login
const payload = await getPayload({ config })
const authConfig = payload.collections[collection]?.config.auth
if (!authConfig) {
throw new Error(`Collection ${String(collection)} is not an auth collection`)
}
await login({ collection, config, email, password, serverAdapter }) Type guard
function isAuthCollection(payload: Payload, slug: string): slug is AuthCollectionSlug {
return !!payload.collections[slug]?.config.auth
} Try / catch
// Plain Error (not APIError) — catch broadly and report config error
try {
await login({ collection, config, email, password, serverAdapter })
} catch (e) {
if (e instanceof Error && /No auth config/.test(e.message)) {
// surface a configuration error to the operator
} else throw e
} Prevention
- Use the typed `AuthCollectionSlug` so slug typos fail at compile time.
- Confirm the collection is declared with `auth: true` in config.
- Pass the same `config` to `getPayload`/`login` that defines the collection.
When it happens
Trigger: The adapter's `login({ collection, ... })` is called with a slug that is misspelled, not registered in `config.collections`, or registered without `auth: true`. The lookup `payload.collections[collection]` returns undefined (`.config.auth` → undefined).
Common situations: Frontend hard-codes a collection slug that was renamed in config; a collection was removed but the auth UI still references it; `auth` was not set on the collection config (it's a content collection, not an auth collection); config loaded asynchronously and `getPayload` resolved a stale/partial instance.
Related errors
- Email or username is required.
- validation:required
- error:notAllowedToPerformAction
- error:notAllowedToPerformAction
- error:notAllowedToPerformAction
AI-assisted analysis of payloadcms/payload@00c58b35c0 (2026-08-12).
Data as JSON: /api/errors/c7427d0ed4f98a0c.
Report an issue: GitHub.