Repository navigation
fix: catch NoSuchEntityException in InvalidSkuProcessor for bundle products - #40883
kapil971390 wants to merge 6 commits into
Conversation
…oducts productRepository->get($sku) in retrieveInvalidSkuList() had no exception handling for the case where a bundle product is deleted between the initial retrieveProductIdsBySkus() lookup and the repository fetch. This caused an uncaught NoSuchEntityException to propagate up and fail the entire batch when using POST /V1/products/base-prices with bundle products. Apply the same try/catch pattern used in ACP2E-4998 (TierPriceValidator): catch NoSuchEntityException and treat the SKU as invalid so the rest of the batch continues processing. Fixes magento#40882
|
Hi @kapil971390. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
@magento run Unit Tests, Static Tests, WebAPI Tests |
|
@magento run Static Tests |
|
All tests passing. Re-triggering CLA check. |
ilnytskyi
left a comment
There was a problem hiding this comment.
@kapil971390 Thank you for your contribution!
Could you cover your fix with unit tests?
Also please sync your branch with latest 2.4-develop and then run
@magento run all tests
|
Thanks for the review. Added unit tests for the new catch block in InvalidSkuProcessorTest - one covering the single deleted-SKU case, one covering that a deleted bundle product doesn't stop the rest of the batch from being processed. Both pass locally. Branch is synced with 2.4-develop now too. @magento run all tests |
|
@magento run all tests |
|
@magento run Database Compare, WebAPI Tests |
ilnytskyi
left a comment
There was a problem hiding this comment.
PR ports similar fix from quality patch into existing code
Description
InvalidSkuProcessor::retrieveInvalidSkuList()callsproductRepository->get($sku)without catchingNoSuchEntityExceptionfor bundle products. If a bundle product is deleted between the initialretrieveProductIdsBySkus()lookup and the repository fetch, the exception propagates uncaught and fails the entirePOST /V1/products/base-pricesbatch.Fixes #40882
Root cause
BasePriceStoragealways passes$this->priceTypeAllowed = 1as$allowedPriceTypeValue, so this code path is reached for every bundle product in a batch.Fix
Applied the same try/catch pattern used in ACP2E-4998 (
TierPriceValidator::checkQuantity()):Related
ACP2E-4998 fixed the same pattern in
TierPriceValidator::checkQuantity()butInvalidSkuProcessorwas not updated at the same time.Test plan
POST /V1/products/base-priceswith a batch containing a bundle product that is deleted concurrently — should report the SKU as invalid and continue processing the rest of the batchPOST /V1/products/base-priceswith only valid bundle products — no behavior changePOST /V1/products/base-priceswith only simple products — no behavior change (code path not reached)