Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename is too long exception when importing media images #29377

Closed
1 of 5 tasks
stephansteiner opened this issue Aug 4, 2020 · 9 comments · Fixed by #30011
Closed
1 of 5 tasks

Filename is too long exception when importing media images #29377

stephansteiner opened this issue Aug 4, 2020 · 9 comments · Fixed by #30011
Assignees
Labels
Component: File Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P3 May be fixed according to the position in the backlog. Progress: done Reported on 2.4.0 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@stephansteiner
Copy link

stephansteiner commented Aug 4, 2020

I'm trying to import product images with very long names.
295744_20200804070722_tanzteppich_colorx_150_plus_1004222_16330_chroma_blau_schw_150cm_lfm.jpg
There is a limit in Magento of 90 characters which I don't fully understand.
All unix filesstems support 255 characters, Windows as well, the value column in catalog_product_entity_varchar is 255 characters, the value column in catalog_product_entity_media_gallery is also 255 characters.

The limit of 90 characters is annotated in vendor/magento/framework/File/Uploader.php with the following comment:
// account for excessively long filenames that cannot be stored completely in database

I don't know of any database column less than 255 characters. So the hard limit could be much higher, like 240 characters (the filename in the media gallery will be prepended with the dispretion path of /2/9/ which is 5 extra characters.
Tested on Magento 2.3, on Magento 2.4 there is the same limitation.

Preconditions (*)

  1. Magento 2.4-develop
  2. create a simple product import csv file and prepare a very long filename for the product image. You can use exampled provided along with this bug report.

Steps to reproduce (*)

  1. put a very long named product image into var/import/images/ as described in the guide here https://docs.magento.com/user-guide/system/data-import-product-images.html
  2. In the product csv specify the very long image filename for a product image attribute (like base_image).
  3. Import the product csv file in the Magento backend using System > Data Transfer > Import. For import settings use:
    Entity Type: Products
    Import Behaviour: Add/Update
    Validation Strategy: Stop on Error
    Example CSV file: sample_long.csv.txt

Expected result (*)

  1. Product will be imported without problems and have product image assigned

Actual result (*)

  1. "Check Data" passes, while Import itself will fail due to the fact the product image cannot be saved because of exceeded length

  2. The error message is misleading as it says: "1. Imported resource (image) could not be downloaded from external resource due to timeout or access permissions in row(s): 1"
    image

  3. When using a shorter image name, import works.


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

  • 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”.
@m2-assistant
Copy link

m2-assistant bot commented Aug 4, 2020

Hi @stephansteiner. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@ghost ghost added this to Ready for QA in Community Backlog Aug 4, 2020
@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Aug 4, 2020
@stephansteiner stephansteiner changed the title Filename is too long when import media images Filename is too long exception when import media images Aug 4, 2020
@stephansteiner stephansteiner changed the title Filename is too long exception when import media images Filename is too long exception when importing media images Aug 4, 2020
@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Aug 4, 2020

I had similar experience of uploading image with long name to the product images, it's really not obvious why magento can't handle it. It could be fixed in few ways:

  1. increase file name limit
  2. make a rename if we got this limit

I'll add "Severity: S2", as it's not breaking critical functionality, but quite annoying when you're getting this issue. But TBH fix is quite simple from customer perspective - just rename the file and try again

@ihor-sviziev ihor-sviziev added the Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. label Aug 4, 2020
@stephansteiner
Copy link
Author

Renaming the file is not an option - especially when we migrate the shop from M1 to M2, where the import from the ERP system worked with Magento1 SOAP API with longer filenames. On the other hand our customer needs "seo-optimized" image names that contain the product name (plus some version info we need for our import/upgrade logic). So 90 characters for a dispretion path is very "short" if you have longer product names.
So, I'll have to stick with the option to remove this limit of 90 characters in vendor/magento/framework/File/Uploader.php.

@engcom-Delta engcom-Delta self-assigned this Aug 12, 2020
@m2-assistant
Copy link

m2-assistant bot commented Aug 12, 2020

Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Delta engcom-Delta added Component: File Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 12, 2020
@ghost ghost unassigned engcom-Delta Aug 12, 2020
@ghost ghost moved this from Ready for QA to Ready for Dev in Community Backlog Aug 12, 2020
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Delta
Thank you for verifying the issue. Based on the provided information internal tickets MC-36662 were created

Issue Available: @engcom-Delta, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@ghost ghost removed the Progress: ready for QA label Aug 12, 2020
@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Aug 12, 2020
@sdzhepa sdzhepa added the Priority: P3 May be fixed according to the position in the backlog. label Aug 13, 2020
@ghost ghost moved this from Ready for Dev to PR In Progress in Community Backlog Sep 11, 2020
@lfluvisotto
Copy link
Contributor

lfluvisotto commented Sep 11, 2020

I researched about it.

According to https://en.wikipedia.org/wiki/Comparison_of_file_systems , I know that wikipedia isn't the best reference to find things related, but most of operation systems the maximum filename length is 255 characters.

https://www.ibm.com/support/knowledgecenter/SSEQVQ_8.1.9/client/c_cmd_filespecsyntax.html

On this documentation above says:

  • On AIX, Solaris, and Mac: The maximum number of characters for a file name is 255.
  • On Linux: The maximum length for a file name is 255 bytes.
  • The maximum number of bytes for a file name and file path when combined is 6255. However, the file name itself cannot exceed 255 bytes

https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-shares--directories--files--and-metadata

On this documentation above from azure says:

Directory and file component names must be no more than 255 characters in length.

So, the path + filename cannot exceed 255 characters in length.

The current logic is incorrect because it's checking only the basename (filename), not the entire path (directory + filename).

So, I created a pull request fixing it:

#30011

@ihor-sviziev

@ghost ghost assigned lfluvisotto Sep 11, 2020
@sidolov sidolov added this to Ready for Development in Low Priority Backlog Sep 24, 2020
@m2-community-project m2-community-project bot moved this from Ready for Development to Pull Request In Progress in Low Priority Backlog Sep 24, 2020
@m2-community-project m2-community-project bot added the Progress: PR Created Indicates that Pull Request has been created to fix issue label Sep 24, 2020
@magento-engcom-team magento-engcom-team added Progress: ready for dev and removed Progress: PR Created Indicates that Pull Request has been created to fix issue labels Sep 24, 2020
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in Low Priority Backlog Sep 24, 2020
@sidolov sidolov moved this from Ready for Development to Dev In Progress in Low Priority Backlog Sep 24, 2020
@magento-engcom-team
Copy link
Contributor

Hi @stephansteiner. Thank you for your report.
The issue has been fixed in #30011 by @lfluvisotto in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.2 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Sep 25, 2020
@m2-community-project m2-community-project bot moved this from Dev In Progress to Done in Low Priority Backlog Sep 25, 2020
@magento-engcom-team magento-engcom-team added the Reported on 2.4.0 Indicates original Magento version for the Issue report. label Nov 13, 2020
@m2-community-project m2-community-project bot removed this from PR In Progress in Community Backlog Nov 13, 2020
@pemann
Copy link

pemann commented Jan 25, 2022

Why this "fix" was reverted in 2.4.3?
See commit "MC-41788": db19d6d

@slavko98
Copy link

slavko98 commented Dec 21, 2022

This issue seems to have been fixed "again" in Magento v2.4.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: File Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P3 May be fixed according to the position in the backlog. Progress: done Reported on 2.4.0 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Development

Successfully merging a pull request may close this issue.

8 participants