Skip to content

Inventory source item's source_code is case insensitive during insert, but case sensitive during read #38488

Open
@bap14

Description

@bap14

Preconditions and environment

  • Magento version: 2.4.6-p4

Steps to reproduce

  1. Create at least one additional custom stock source
Source NameSource Code
Warehouse Alphawarehouse_alpha
Warehouse Bravowarehouse_bravo
  1. Create a new stock associated to the website
  2. Associate the custom sources to the new stock
  3. Utilizing the API, create an inventory source item
curl 'https://magento-opensource.test/rest/default/V1/inventory/source-items' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <auth_token>' \
--data '{
    "sourceItems": [
        {
            "sku": "24-MB01",
            "source_code": "Warehouse_Bravo",
            "quantity": 5000,
            "status": 1
        }
    ]
}
'
  1. Log in to the admin panel
  2. Navigate to the catalog products grid

Expected result

The product grid renders

Actual result

An error is displayed:

Warning: Undefined array key "Warehouse_Bravo" in /var/www/html/vendor/magento/module-inventory-catalog-admin-ui/Ui/DataProvider/Product/Listing/Modifier/QuantityPerSource.php on line 142

Additional information

This appears to be because the data in the source_code column is collated to be case insensitive (utf8mb3_general_ci). The data provider for the admin grid loads the source items for the product into an array, keyed by the source_code value. While iterating over the product's source items it looks for the key in the array; however, the source item's source_code value doesn't match the source_code for the inventory source.

image

The workaround to this is to either delete the offending records, or override the private function to force the comparison to be done in a case-insensitive manner.

Release note

Fixes an issue where using the inventory/source-items API an incorrectly cased source_code value can cause the admin grid to fail to render with error Warning: Undefined array key "<source code>"

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: CatalogComponent: InventoryIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: dev in progressReported on 2.4.6-p4Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions