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

Screenshot file name too long warning when Bytes exceeded #2403

Closed
rafaelcaviquioli opened this issue Aug 28, 2018 · 16 comments · Fixed by #8175 · May be fixed by Omrisnyk/npm-lockfiles#145 or Omrisnyk/npm-lockfiles#164
Closed

Screenshot file name too long warning when Bytes exceeded #2403

rafaelcaviquioli opened this issue Aug 28, 2018 · 16 comments · Fixed by #8175 · May be fixed by Omrisnyk/npm-lockfiles#145 or Omrisnyk/npm-lockfiles#164
Assignees
Labels
Milestone

Comments

@rafaelcaviquioli
Copy link

rafaelcaviquioli commented Aug 28, 2018

Current behavior:

Currently I use BDD to document acceptance test cases, each test scenario is well detailed, Cypress uses the description of "it" to create the screenshot file name, but when "it" exceeds 255 characters it is not possible to create the screenshot file.

  6) As a quality manager, i would like to query the occurence history to find information about them GIVEN that im onthe search sreen, WHEN i fill in the ocurrence date fields, check the only delayed ones box and click on the filter button, THEN i see the filtered results:
     Error: ENAMETOOLONG: name too long, open '/home/node/cypress/screenshots/tools/us6.spec.js/As a quality manager iwould like to query the occurence history to find information about them -- GIVEN that im on the search sreen WHEN i fill in the ocurrence date fields check the only delayed ones box and click on the filter button THEN i see the filteredresults (failed).png'

Desired behavior:

  1. I hope Cypress allows me to change the name of the destination file from the screenshot before it writes it.
  2. Or, I hope Cypress will worry about the size of the file before it writes it and limits it to 255 characters.

Steps to reproduce:

  1. Create a test case with "it" description too long, bigger then 255 caracteres.
  2. Make a test case broken.
  3. Run tests.
  4. Look the verbose log, the screenshot not was created.

Versions

Cypress: 3.0.3
Browser: Chrome 67

@chrisbreiding
Copy link
Contributor

Thanks for reporting this. We definitely need to catch that error and truncate the file name as needed. I'm hesitant to always truncate at an arbitrary character length since that's going to be OS-dependent and there may be an operating system with an even lower limit.

Speaking of which, on what operating system are you encountering this?

Unfortunately, there's no way to change the screenshot path before it's written to disk. We'd need to add a new plugin event that enables that.

@rafaelcaviquioli
Copy link
Author

Thank's for response @chrisbreiding , we are running on Ubuntu 16, Ubuntu 18 and Docker image cypress/browsers:chrome67

@lslv1243

This comment has been minimized.

1 similar comment
@JulianoGTZ
Copy link

JulianoGTZ commented Aug 31, 2018

+1

@jennifer-shehane
Copy link
Member

I also got this issue on our internal tests. 🙈

Error: ENAMETOOLONG: name too long, open '/root/cypress-dashboard/cypress/screenshots/project_spec.coffee/Project -- route to project -- permission to view private project -- grace period banner -- billing feature flag ON -- as owner or admin -- not over test recordings -- displays banner with link to billing (failed).png'

@jennifer-shehane jennifer-shehane added the stage: ready for work The issue is reproducible and in scope label Oct 19, 2018
@lilaconlee lilaconlee self-assigned this Oct 22, 2018
@lilaconlee lilaconlee added this to the Sprint 8 milestone Oct 22, 2018
@jennifer-shehane jennifer-shehane removed stage: ready for work The issue is reproducible and in scope labels Jan 16, 2019
@AlDemion
Copy link

AlDemion commented May 8, 2019

I got the same situation with 3.2.0 version. @lilaconlee Can you please look here?

cypress:server:socket automation:request take:screenshot { 
  titles: [ 
    'WMED: [STORY] Тестовые сценарии для CI', 
    'Сценарии:', 
    'Сценарий 2: Создание обращения, создание медзаписи, привязка обращения к медзаписи', 
    '- Сценарий 2' 
  ], testId: 'r7', simple: true, testFailure: true, capture: 'runner', clip: { x: 0, y: 0, width: 1050, height: 932 }, viewport: { width: 1050, height: 932 }, scaled: true, blackout: [], startTime: '2019-05-08T09:03:20.993Z' 
}
cypress:server:screenshot (s1) capturing screenshot { 
  titles: [ 
    'WMED: [STORY] Тестовые сценарии для CI', 
    'Сценарии:', 
    'Сценарий 2: Создание обращения, создание медзаписи, привязка обращения к медзаписи', 
    '- Сценарий 2' 
  ], testId: 'r7', simple: true, testFailure: true, capture: 'runner', clip: { x: 0, y: 0, width: 1050, height: 932 }, viewport: { width: 1050, height: 932 }, scaled: true, blackout: [], startTime: '2019-05-08T09:03:20.993Z', specName: 'WMED_UAT_Scenarios_For_CI_spec.js' }
...
cypress:server:screenshot (s1) save /jenkins-slave/workspace/test-wmed/qa/cypress/wmed_ci/cypress/screenshots/WMED_UAT_Scenarios_For_CI_spec.js/WMED [STORY] Тестовые сценарии для CI -- Сценарии -- Сценарий 2 Создание обращения, создание медзаписи, привязка обращения к медзаписи -- - Сценарий 2 (failed).png
cypress:server:screenshot (s1) clearing 0 cached multipart images
...
cypress:server:project onMocha fail
cypress:server:reporter got mocha event 'fail' with args: [ 
  { 
    id: 'r7', 
    title: '- Сценарий 2', 
    err: { 
      message: 'ENAMETOOLONG: name too long, open \'/jenkins-slave/workspace/test-wmed/qa/cypress/wmed_ci/cypress/screenshots/WMED_UAT_Scenarios_For_CI_spec.js/WMED [STORY] Тестовые сценарии для CI -- Сценарии -- Сценарий 2 Создание обращения, создание медзаписи, привязка обращения к медзаписи -- - Сценарий 2 (failed).png\'', 
      name: 'Error', 
      stack: 'Error: ENAMETOOLONG: name too long, open \'/jenkins-slave/workspace/test-wmed/qa/cypress/wmed_ci/cypress/screenshots/WMED_UAT_Scenarios_For_CI_spec.js/WMED [STORY] Тестовые сценарии для CI -- Сценарии -- Сценарий 2 Создание обращения, создание медзаписи, привязка обращения к медзаписи -- - Сценарий 2 (failed).png\'\n\n' }, 
      state: 'failed', 
      body: 'function (

@jennifer-shehane
Copy link
Member

@AlDemion Thanks so much for providing the logs.

I tested nesting some long suite titles, which passed for me.

I then tried pasting in the exact titles of your test suites - this also passed for me.

I changed the filename, so that the path would be really long - this also passed for me!

So, I haven't been able to recreate completely with my guesswork.

Can you post the full body of the error message in the DEBUG log? When you pasted, you cut it off at state: 'failed', body: function ( - I need the info printed here to see the stack of where this is being thrown.

@kuznetsovaOk
Copy link

kuznetsovaOk commented Sep 5, 2019

Hello! I've come across with the issue that even after Cypress truncate extra letters from file name I still get ENAMETOOLONG error in CI.

I figured out that the cause of that is using Cyrillic letters in Cypress tests.

  • My filesystem has file name limit in 255 bytes (not characters).
  • One Cyrillic letter takes 2 bytes instead of 1 byte.
  • When Cypress checks if the file name is not too long it seems to be checking characters but not bytes.

So it happens that file name with Cyrillic letter pass the Cypress validation but not file system validation.

@AlDemion maybe you have the same issue. I've checked how many characters vs bytes in your example in apfs:

echo "WMED [STORY] Тестовые сценарии для CI -- Сценарии -- Сценарий 2 Создание обращения, создание медзаписи, привязка обращения к медзаписи -- - Сценарий 2 (failed).png" | wc -m

Logs 164

echo "WMED [STORY] Тестовые сценарии для CI -- Сценарии -- Сценарий 2 Создание обращения, создание медзаписи, привязка обращения к медзаписи -- - Сценарий 2 (failed).png" | wc -c

Logs 268

And it seems that your filename might actually exceed your filesystem limits

@jennifer-shehane
Copy link
Member

@kuznetsovaOk Thanks for the explanation @kuznetsovaOk, this is amazing, thank you!

The max filename length is dependent on the file system that Cypress would be running in and all of them are listed here: https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits

But yeah, I think the key takeaway here is that chars !== bytes. Reopening to address bytes issues.

@adrianpaterson
Copy link

When is this issue expected to be resolved? This is a breaking issue for build pipelines so should be seen as a high priority. Not sure why in over a year it hasn't yet been fixed!

@AlDemion
Copy link

AlDemion commented Nov 8, 2019

Yeah @kuznetsovaOk You got the point. It seems that all the problems in the file system limits. But I can't change the filesystem, so one hope is that the issue will be fixed by truncating the filename or by using a randomly generated string for the screenshot name.

@flotwig
Copy link
Contributor

flotwig commented Nov 8, 2019

The patch should be simple enough, if someone having this issue wants to open a PR. We most likely just need to use Buffer.byteLength instead of String.prototype.length here:

if names[index].length > maxFileNameLength

@jbergknoff-rival
Copy link

We're running into this in the cypress/included:4.2.0 container with no Cyrillic characters. The breakdown from the ENAMETOOLONG error message is like this:

<96 character path to spec file>/<131 character spec title> -- before all hook (failed).png

A total of 260 characters. Is there any workaround?

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Mar 25, 2020
@jennifer-shehane jennifer-shehane added the good first issue Good for newcomers label Mar 25, 2020
@jennifer-shehane jennifer-shehane changed the title Screenshot file name too long Screenshot file name too long warning when Bytes exceeded Mar 25, 2020
@flotwig
Copy link
Contributor

flotwig commented Aug 4, 2020

The original issue opened by @rafaelcaviquioli was fixed, by this PR: #2635

The issue @AlDemion and @kuznetsovaOk are running in to seems to be caused by the difference between String.length and Buffer.byteLength as described here: #2403 (comment)

I've opened a PR that truncates filenames to a maximum of bytes on all operating systems.


@jbergknoff-rival you can try building from my PR and see if it fixes your issue, or if you want, you can share the filenames that are causing problems and I can try to see. Any Unicode character could cause this problem.

If you don't have any Unicode in your filenames, could you also share debug logs from the time that issue occurs?

@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Aug 4, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Aug 10, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 10, 2020

The code for this is done in cypress-io/cypress#8175, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 20, 2020

Released in 5.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v5.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.