{"record":{"id":"d58d2b11a2351651","repo":"medusajs/medusa","slug":"collection-with-id-req-params-id-not-found","errorCode":null,"errorMessage":"Collection with id \"${req.params.id}\" not found","messagePattern":"Collection with id \"(.+?)\" not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/collections/[id]/route.ts","lineNumber":39,"sourceCode":"    req.scope,\n    req.queryConfig.fields\n  )\n\n  res.status(200).json({ collection })\n}\n\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<\n    AdminUpdateCollectionType & AdditionalData,\n    HttpTypes.AdminCollectionParams\n  >,\n  res: MedusaResponse<HttpTypes.AdminCollectionResponse>\n) => {\n  const existingCollection = await refetchCollection(req.params.id, req.scope, [\n    \"id\",\n  ])\n  if (!existingCollection) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Collection with id \"${req.params.id}\" not found`\n    )\n  }\n\n  const { additional_data, ...rest } = req.validatedBody\n\n  await updateCollectionsWorkflow(req.scope).run({\n    input: {\n      selector: { id: req.params.id },\n      update: rest,\n      additional_data,\n    },\n  })\n\n  const collection = await refetchCollection(\n    req.params.id,\n    req.scope,","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/collections/[id]/route.ts#L21-L57","documentation":"The POST (update) /admin/collections/:id route refetches the product collection before updating; if the collection id does not exist it throws NOT_FOUND (HTTP 404).","triggerScenarios":"POST /admin/collections/:id updating a product collection whose id does not exist or was deleted.","commonSituations":"Collection deleted while the edit drawer was open in the dashboard; batch import scripts referencing stale collection ids.","solutions":["Verify via GET /admin/collections/:id before updating","Re-list collections to refresh ids after deletions","Handle 404 by resetting the edit form and notifying the user"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const exists = (await sdk.admin.product.listCollections({ id })).collections.length > 0\nif (!exists) throw new Error(\"collection deleted\")","typeGuard":"null","tryCatchPattern":"try { await sdk.admin.product.updateCollection(id, payload) } catch (e) { if (e.statusCode === 404) { refreshCollections(); notify(\"Collection no longer exists\") } else throw e }","preventionTips":["Reload collection data before saving edits","Idempotent import scripts should skip 404s"],"tags":["admin-api","collections","products","update"],"backgroundTag":"http-404-update-missing-resource","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}