Skip to content

Remote storage sync fails on similar image filenames (with hyphens and underscores) #34337

Closed
@lphilippo

Description

@lphilippo

Preconditions (*)

  1. Magento 2.4.3 CE
  2. Activate remote storage with AWS S3

Steps to reproduce (*)

  1. Use an image where the filename has an hyphen as a second character: 5-100.png
  2. Use a second image with the same first character, but an underscore as second: 5_100.png
  3. Synchronise remote storage with bin/magento remote-storage:sync

Expected result (*)

  1. Both images will be synchronised with the remote storage.

Actual result (*)

  1. The first image (with dash) is being stored correctly.
  2. The second image fails with the message Notice: Undefined index: media/catalog/product/5/_ in /src/vendor/magento/module-remote-storage/Driver/Adapter/Cache/Generic.php on line 197
  3. The sync process halts.

Technical background

The issue lies in RemoteStorage/Driver/Adapter/Cache/Generic. The dashes are converted to underscore in the internal workings of the cache adapter (line 192). This causes that the underscore variant receives the cache that the dash variant has already created. However, the path inside the $meta has been unaffected by the underscore conversion and the mismatch triggers the exceptions. This was very easily circumvented by the following change to check both non-empty content as well as existence, which prevents that the incorrect cache is being used for the underscore variant:

<             if (!$meta[$path]) {
---
>             if (empty($meta[$path])) {

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

Additional Info

error

[X] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: CatalogComponent: AwsSIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneReported on 2.4.3Indicates 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

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions