{"record":{"id":"42c894823f3560c0","repo":"medusajs/medusa","slug":"not-found-42c894","errorCode":"NOT_FOUND","errorMessage":"Product variant with id: ${req.params.id} was not found","messagePattern":"Product variant with id: (.+?) was not found","errorType":"exception","errorClass":"MedusaError","httpStatus":404,"severity":"error","filePath":"packages/medusa/src/api/store/product-variants/[id]/route.ts","lineNumber":61,"sourceCode":"  const { data: variants = [] } = await query.graph(\n    {\n      entity: \"variant\",\n      filters: {\n        ...req.filterableFields,\n        id: req.params.id,\n      },\n      fields: req.queryConfig.fields,\n      context,\n    },\n    {\n      locale: req.locale,\n    }\n  )\n\n  const variant = variants[0]\n\n  if (!variant) {\n    throw new MedusaError(\n      MedusaError.Types.NOT_FOUND,\n      `Product variant with id: ${req.params.id} was not found`\n    )\n  }\n\n  if (withInventoryQuantity) {\n    await wrapVariantsWithInventoryQuantityForSalesChannel(req, [variant])\n  }\n\n  await wrapVariantsWithTaxPrices(req, [variant])\n\n  res.json({ variant })\n}\n","sourceCodeStart":43,"sourceCodeEnd":75,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/medusa/src/api/store/product-variants/[id]/route.ts#L43-L75","documentation":"Thrown by GET /store/product-variants/:id when the variant lookup returns no variant for the given id. The variant may not exist, be deleted, or belong to a product not available in the store. Returns 404 NOT_FOUND.","triggerScenarios":"Requesting /store/product-variants/variant_... with a nonexistent/deleted variant id, or a variant of an unpublished product; also when region/currency filters exclude it.","commonSituations":"Stale cart or wishlist referencing deleted variants; cached variant ids after catalog syncs; variants removed when a product's options changed.","solutions":["Verify the variant via GET /store/products/:id (which includes variants) or the variants list endpoint","Invalidate cached variant references (carts, wishlists, recently-viewed) when variants change","Handle the 404 gracefully with a fallback to the parent product page"],"exampleFix":"// before\nconst { variant } = await sdk.store.productVariant.retrieve('variant_deleted')\n\n// after\ntry {\n  const { variant } = await sdk.store.productVariant.retrieve(id)\n} catch {\n  redirect(`/products/${productId}`)\n}","handlingStrategy":"fallback","validationCode":"const { variants } = await sdk.store.productVariant.list({ id: [variantId] })\nif (!variants.length) redirect(`/products/${productId}`)","typeGuard":null,"tryCatchPattern":"try {\n  const { variant } = await sdk.store.productVariant.retrieve(id)\n} catch (e: any) {\n  if (e.type === 'not_found') return fallbackToProduct(productId)\n  throw e\n}","preventionTips":["Re-validate cart/wishlist variant ids on catalog changes","Fall back to parent product page on 404","Clean up recently-viewed caches after syncs"],"tags":["store-api","product-variant","not-found"],"backgroundTag":"resource-not-found-by-id","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}