fix(medusa): In product isolation, throw if product not found (#5224)
**What** Throw not found error if product does not exists
This commit is contained in:
committed by
GitHub
parent
4c8836b488
commit
c68ba63c1b
5
.changeset/tricky-pears-walk.md
Normal file
5
.changeset/tricky-pears-walk.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): In product isolation, throw if product not found
|
||||
@@ -1,6 +1,7 @@
|
||||
import { PricingService, ProductService } from "../../../../services"
|
||||
import IsolateProductDomainFeatureFlag from "../../../../loaders/feature-flags/isolate-product-domain"
|
||||
import { defaultAdminProductRemoteQueryObject } from "./index"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
|
||||
/**
|
||||
* @oas [get] /admin/products/{id}
|
||||
@@ -100,6 +101,13 @@ async function getProductWithIsolatedProductModule(req, id, retrieveConfig) {
|
||||
|
||||
const [product] = await remoteQuery(query)
|
||||
|
||||
if (!product) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_FOUND,
|
||||
`Product with id: ${id} not found`
|
||||
)
|
||||
}
|
||||
|
||||
product.profile_id = product.profile?.id
|
||||
|
||||
return product
|
||||
|
||||
@@ -11,6 +11,7 @@ import { PriceSelectionParams } from "../../../../types/price-selection"
|
||||
import { cleanResponseData } from "../../../../utils"
|
||||
import IsolateProductDomain from "../../../../loaders/feature-flags/isolate-product-domain"
|
||||
import { defaultStoreProductRemoteQueryObject } from "./index"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
|
||||
/**
|
||||
* @oas [get] /store/products/{id}
|
||||
@@ -176,6 +177,13 @@ async function getProductWithIsolatedProductModule(req, id: string) {
|
||||
|
||||
const [product] = await remoteQuery(query)
|
||||
|
||||
if (!product) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.NOT_FOUND,
|
||||
`Product with id: ${id} not found`
|
||||
)
|
||||
}
|
||||
|
||||
product.profile_id = product.profile?.id
|
||||
|
||||
return product
|
||||
|
||||
Reference in New Issue
Block a user