{"record":{"id":"0e9673aa26383419","repo":"payloadcms/payload","slug":"the-collection-with-slug-string-collectionslug-0e9673","errorCode":null,"errorMessage":"The collection with slug ${String(collectionSlug)} can't be found. Delete Operation.","messagePattern":"The collection with slug (.+?) can't be found\\. Delete Operation\\.","errorType":"http","errorClass":"APIError","httpStatus":500,"severity":"error","filePath":"packages/payload/src/collections/operations/local/delete.ts","lineNumber":170,"sourceCode":"): Promise<BulkOperationResult<TSlug, TSelect> | TransformCollectionWithSelect<TSlug, TSelect>> {\n  const {\n    id,\n    collection: collectionSlug,\n    depth,\n    disableTransaction,\n    overrideAccess = true,\n    overrideLock,\n    populate,\n    select,\n    showHiddenFields,\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. Delete Operation.`,\n    )\n  }\n\n  const args = {\n    id,\n    collection,\n    depth,\n    disableTransaction,\n    overrideAccess,\n    overrideLock,\n    populate,\n    req: await createLocalReq(options as CreateLocalReqOptions, payload),\n    select,\n    showHiddenFields,\n    trash,\n    where,\n  }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/payload/src/collections/operations/local/delete.ts#L152-L188","documentation":"Thrown by the Local API `delete` wrapper in packages/payload/src/collections/operations/local/delete.ts:170 when `payload.delete({ collection })` references a slug not in `payload.collections`. Defaults to HTTP 500 (no status supplied). Thrown before transaction or access handling begins, so nothing is partially deleted.","triggerScenarios":"Calling `payload.delete({ collection: 'comment', where: {...} })` with a misspelled slug; deleting through a cleanup job that was written against a collection since removed; passing a slug sourced from a config file that is out of sync with the running Payload instance.","commonSituations":"Collection renamed or removed in a refactor; plural/singular mismatch; dynamic slug from env var; `as CollectionSlug` cast hiding a typo.","solutions":["Verify the slug against the collection config and `Object.keys(payload.collections)`.","If deleting in a loop over many collections, filter the list to registered slugs first.","Ensure `payload.init()` completed and the relevant collection plugin is loaded.","Stop asserting dynamic strings as `CollectionSlug`."],"exampleFix":"// before\nawait payload.delete({ collection: 'tag', where: { id: { equals: id } } }) // slug is 'tags'\n\n// after\nawait payload.delete({ collection: 'tags', where: { id: { equals: id } } })","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, 'tags')\nawait payload.delete({ collection: 'tags', where: { id: { equals: id } } })","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.delete({ collection: slug, where: { id: { equals: id } } })\n}","tryCatchPattern":"try {\n  await payload.delete({ collection: slug, where })\n} catch (err) {\n  if (err instanceof APIError && /Delete Operation/.test(err.message)) {\n    // unknown slug — fix caller, no retry\n  } else throw err\n}","preventionTips":["When deleting across many collections, filter the list to registered slugs first.","Keep slug constants in sync with the collection config.","Avoid `as CollectionSlug` casts on dynamic slugs."],"tags":["local-api","collection","slug","delete","configuration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}