{"record":{"id":"d84a2a214de95be4","repo":"payloadcms/payload","slug":"the-collection-with-slug-string-collectionslug-d84a2a","errorCode":null,"errorMessage":"The collection with slug ${String(collectionSlug)} can't be found. Find Operation.","messagePattern":"The collection with slug (.+?) can't be found\\. Find Operation\\.","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/payload/src/collections/operations/local/find.ts","lineNumber":229,"sourceCode":"    draft = false,\n    includeLockStatus,\n    joins,\n    limit,\n    overrideAccess = true,\n    page,\n    pagination = true,\n    populate,\n    select,\n    showHiddenFields,\n    sort,\n    trash = false,\n    where,\n  } = options\n\n  const collection = payload.collections[collectionSlug]\n\n  if (!collection) {\n    throw new APIError(\n      `The collection with slug ${String(collectionSlug)} can't be found. Find Operation.`,\n    )\n  }\n\n  return findOperation<TSlug, TSelect>({\n    collection,\n    currentDepth,\n    depth,\n    disableErrors,\n    draft,\n    includeLockStatus,\n    joins,\n    limit,\n    overrideAccess,\n    page,\n    pagination,\n    populate,\n    req: await createLocalReq(options as CreateLocalReqOptions, payload),","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/collections/operations/local/find.ts#L211-L247","documentation":"Thrown by the Local API `find` wrapper in packages/payload/src/collections/operations/local/find.ts:229 when `payload.find({ collection })` references a slug not present in `payload.collections`. Defaults to HTTP 500 (no status passed). Raised before pagination, where-clause parsing, or access control.","triggerScenarios":"Calling `payload.find({ collection: 'post' })` with a typo (real slug `'posts'`); a frontend/server component fetching data with a hardcoded slug after the collection was renamed; calling find in a beforeInit hook before collections are registered.","commonSituations":"Stale slug constant after a rename; singular/plural confusion; `as CollectionSlug` cast on dynamic input; collection registered by a plugin that isn't loaded in this build.","solutions":["Match the slug to the collection config's `slug` value exactly.","Log `Object.keys(payload.collections)` to confirm registration at runtime.","Make sure `payload.init()` resolved before the find call.","Avoid `as CollectionSlug` casts on runtime strings."],"exampleFix":"// before\nconst { docs } = await payload.find({ collection: 'post' }) // slug is 'posts'\n\n// after\nconst { docs } = await payload.find({ collection: 'posts' })","handlingStrategy":"validation","validationCode":"function assertCollectionSlug(payload: Payload, slug: string): void {\n  if (!(slug in payload.collections)) {\n    throw new Error(`Unknown collection slug '${slug}'`)\n  }\n}\nassertCollectionSlug(payload, 'posts')\nawait payload.find({ collection: 'posts' })","typeGuard":"const slugIsRegistered = (payload: Payload, slug: string): slug is CollectionSlug =>\n  slug in (payload.collections as Record<string, unknown>)\n\nif (slugIsRegistered(payload, slug)) {\n  await payload.find({ collection: slug })\n}","tryCatchPattern":"try {\n  await payload.find({ collection: slug })\n} catch (err) {\n  if (err instanceof APIError && /Find Operation/.test(err.message)) {\n    // unknown slug — log registered slugs and correct\n  } else throw err\n}","preventionTips":["Share slug constants between config and callers.","Await payload.init() in scripts before find calls.","Avoid `as CollectionSlug` casts on dynamic input."],"tags":["local-api","collection","slug","find","configuration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}