{"record":{"id":"07e6f4b4e58d5c65","repo":"medusajs/medusa","slug":"product-category-with-id-req-params-id-was-not","errorCode":null,"errorMessage":"Product category with id: ${req.params.id} was not found","messagePattern":"Product category with id: (.+?) was not found","errorType":"http","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/product-categories/[id]/route.ts","lineNumber":33,"sourceCode":"\nexport const GET = async (\n  req: AuthenticatedMedusaRequest<\n    HttpTypes.AdminProductCategoryListParams\n  >,\n  res: MedusaResponse<AdminProductCategoryResponse>\n) => {\n  const {\n    data: [category],\n  } = await refetchEntities({\n    entity: \"product_category\",\n    idOrFilter: { id: req.params.id, ...req.filterableFields },\n    scope: req.scope,\n    fields: req.queryConfig.fields,\n    pagination: req.queryConfig.pagination,\n  })\n\n  if (!category) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Product category with id: ${req.params.id} was not found`\n    )\n  }\n\n  res.json({ product_category: category })\n}\n\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<\n    HttpTypes.AdminUpdateProductCategory,\n    HttpTypes.AdminProductCategoryParams\n  >,\n  res: MedusaResponse<AdminProductCategoryResponse>\n) => {\n  const { id } = req.params\n\n  await updateProductCategoriesWorkflow(req.scope).run({","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/product-categories/[id]/route.ts#L15-L51","documentation":"Thrown by GET /admin/product-categories/:id when refetchProductCategory returns nothing. The category is fetched through the product category service/query with the requested fields and pagination; an empty result triggers NOT_FOUND.","triggerScenarios":"Requesting a category id that does not exist, was deleted, or is an internal category excluded from the query.","commonSituations":"UI holding a stale category tree after categories were reorganized/deleted, deleted categories still referenced by products, or wrong-environment ids in scripts.","solutions":["Refresh the category list (GET /admin/product-categories) and use current ids","If products still reference the deleted category, clean up the references and update UI caches","Verify the id comes from the same store/environment"],"exampleFix":"// before\nconst { product_category } = await sdk.admin.productCategory.retrieve(catId)\n\n// after\nconst { product_categories } = await sdk.admin.productCategory.list({ q: name })\nif (!product_categories.some((c) => c.id === catId)) {\n  throw new Error(`Category ${catId} no longer exists`)\n}","handlingStrategy":"validation","validationCode":"const { product_categories } = await sdk.admin.productCategory.list({ id: [catId] })\nif (product_categories.length === 0) throw new Error(`Category ${catId} not found`)","typeGuard":"const isCategory = (v: unknown): v is HttpTypes.AdminProductCategory =>\n  !!v && typeof v === \"object\" && \"id\" in v && \"name\" in v","tryCatchPattern":"try {\n  return await getCategory(catId)\n} catch (e: any) {\n  if (e.statusCode === 404) { refreshCategoryTree(); return null }\n  throw e\n}","preventionTips":["Refetch the category tree after reorganizations","Don't deep-link to deleted categories","Clean up product references to deleted categories"],"tags":["admin","product-categories","not-found","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}