Skip to content

fix: catch NoSuchEntityException in InvalidSkuProcessor for bundle products#40883

Open
kapil971390 wants to merge 2 commits into
magento:2.4-developfrom
kapil971390:fix/invalid-sku-processor-no-such-entity
Open

fix: catch NoSuchEntityException in InvalidSkuProcessor for bundle products#40883
kapil971390 wants to merge 2 commits into
magento:2.4-developfrom
kapil971390:fix/invalid-sku-processor-no-such-entity

Conversation

@kapil971390

@kapil971390 kapil971390 commented Jun 15, 2026

Copy link
Copy Markdown

Description

InvalidSkuProcessor::retrieveInvalidSkuList() calls productRepository->get($sku) without catching NoSuchEntityException for bundle products. If a bundle product is deleted between the initial retrieveProductIdsBySkus() lookup and the repository fetch, the exception propagates uncaught and fails the entire POST /V1/products/base-prices batch.

Fixes #40882

Root cause

// Before — no exception handling
if ($allowedPriceTypeValue
    && $type == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE
    && $this->productRepository->get($sku)->getPriceType() != $allowedPriceTypeValue
) {
    $valueTypeIsAllowed = true;
}

BasePriceStorage always passes $this->priceTypeAllowed = 1 as $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()):

if ($allowedPriceTypeValue
    && $type == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE
) {
    try {
        $product = $this->productRepository->get($sku);
        if ($product->getPriceType() != $allowedPriceTypeValue) {
            $valueTypeIsAllowed = true;
        }
    } catch (NoSuchEntityException $e) {
        // Product was deleted between the ID lookup and repository fetch.
        // Treat as invalid SKU so the rest of the batch continues.
        $skuDiff[] = $sku;
        break;
    }
}

Related

ACP2E-4998 fixed the same pattern in TierPriceValidator::checkQuantity() but InvalidSkuProcessor was not updated at the same time.

Test plan

  • POST /V1/products/base-prices with a batch containing a bundle product that is deleted concurrently — should report the SKU as invalid and continue processing the rest of the batch
  • POST /V1/products/base-prices with only valid bundle products — no behavior change
  • POST /V1/products/base-prices with only simple products — no behavior change (code path not reached)

…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
@m2-assistant

m2-assistant Bot commented Jun 15, 2026

Copy link
Copy Markdown

Hi @kapil971390. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@kapil971390

Copy link
Copy Markdown
Author

@magento run Unit Tests, Static Tests, WebAPI Tests

@kapil971390

Copy link
Copy Markdown
Author

@magento run Static Tests

@kapil971390

Copy link
Copy Markdown
Author

All tests passing. Re-triggering CLA check.

@engcom-Hotel engcom-Hotel added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

InvalidSkuProcessor::retrieveInvalidSkuList() throws uncaught NoSuchEntityException for bundle products — fails entire bulk base-prices batch

3 participants