Skip to content

Undefined array key in ProductRepository getById #40146

@galdiuz

Description

@galdiuz

Preconditions and environment

Tested on Magento 2.4.8-p1.

getById() function in Magento\Catalog\Model\ProductRepository produces an "Undefined array key" if the $productId argument is a string that starts with a valid product ID but contains other trailing characters. For example if you have a product with ID 123 and the function is called with $productId value of "123abc".

Steps to reproduce

  1. Have the ID of a product (123 in this example).
  2. Navigate to the product page but append characters to the ID like /catalog/product/view/id/123abc

Expected result

A 404 not found page.

Actual result

An exception is thrown.

Additional information

No response

Release note

No response

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

No one assigned

    Labels

    Area: SEOComponent: CatalogIssue: 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: PR CreatedIndicates that Pull Request has been created to fix issueProgress: doneReported on 2.4.8-p1Indicates 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