Skip to content

Image filename not necessarily set when logging file not found error #32446

Open
@chris-pook

Description

@chris-pook

Preconditions (*)

  1. Magento 2.4.2

Steps to reproduce (*)

  1. In extension code use \Magento\Framework\Image\Factory::create($filePath) where $filePath is not a valid file.
  2. View var/log/exception.log. Filepath is empty in exception log file.

Description (*)

This appears to be a problem with the Magento Framework GD2 library assuming $this->_fileName has been set where it may not necessarily be the case.

https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Image/Adapter/Gd2.php#L66

The file_exists check is on $fileName (which does have a valid value in the bug scenario here), so I would expect the exception message to use the same value for consistency and to log the correct value.

Expected result (*)

  1. There should be a log entry: main.ERROR: File "filePath" does not exist.

Actual result (*)

  1. There is a log entry: main.ERROR: File "" does not exist.
  2. The file path is empty and it is not clear what file was attempted to be found.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Area: FrameworkComponent: ExceptionIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P3May be fixed according to the position in the backlog.Progress: PR in progressReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S4Affects aesthetics, professional look and feel, “quality” or “usability”.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions