{"record":{"id":"881424852add4bde","repo":"medusajs/medusa","slug":"product-type-with-id-req-params-id-not-found","errorCode":null,"errorMessage":"Product type with id \"${req.params.id}\" not found","messagePattern":"Product type with id \"(.+?)\" not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/admin/product-types/[id]/route.ts","lineNumber":43,"sourceCode":"\n  res.status(200).json({ product_type: productType })\n}\n\nexport const POST = async (\n  req: AuthenticatedMedusaRequest<\n    HttpTypes.AdminUpdateProductType,\n    HttpTypes.AdminProductTypeParams\n  >,\n  res: MedusaResponse<HttpTypes.AdminProductTypeResponse>\n) => {\n  const existingProductType = await refetchProductType(\n    req.params.id,\n    req.scope,\n    [\"id\"]\n  )\n\n  if (!existingProductType) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Product type with id \"${req.params.id}\" not found`\n    )\n  }\n\n  const { result } = await updateProductTypesWorkflow(req.scope).run({\n    input: {\n      selector: { id: req.params.id },\n      update: req.validatedBody,\n    },\n  })\n\n  const productType = await refetchProductType(\n    result[0].id,\n    req.scope,\n    req.queryConfig.fields\n  )\n","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/admin/product-types/[id]/route.ts#L25-L61","documentation":"Thrown by POST /admin/product-types/:id when the existence refetch of the product type returns nothing before updateProductTypesWorkflow runs. The route guards against updating non-existent types.","triggerScenarios":"Calling POST /admin/product-types/ptyp_123 with an update body for a type id that does not exist or was deleted.","commonSituations":"Product type picklists cached client-side after deletion, ids from seed data after a db reset, or cross-environment id copying.","solutions":["List product types (GET /admin/product-types) to verify the id","Recreate the type if it was deleted and you still need it","Invalidate cached type lists after deletions"],"exampleFix":"// before\nawait sdk.admin.productType.update(typeId, { value: \"New Type\" })\n\n// after\nconst { product_types } = await sdk.admin.productType.list()\nif (!product_types.some((t) => t.id === typeId)) {\n  throw new Error(`Product type ${typeId} missing; create it first`)\n}\nawait sdk.admin.productType.update(typeId, { value: \"New Type\" })","handlingStrategy":"validation","validationCode":"const { product_types } = await sdk.admin.productType.list({ id: [typeId] })\nif (product_types.length === 0) throw new Error(`Type ${typeId} not found`)","typeGuard":"const isProductType = (v: unknown): v is HttpTypes.AdminProductType =>\n  !!v && typeof v === \"object\" && \"id\" in v && \"value\" in v","tryCatchPattern":"try {\n  await sdk.admin.productType.update(typeId, patch)\n} catch (e: any) {\n  if (e.statusCode === 404) { await sdk.admin.productType.create(patch); return }\n  throw e\n}","preventionTips":["Re-sync type picklists after deletions","Verify ids after db re-seeds","Upsert instead of blind update in integrations"],"tags":["admin","product-types","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"}