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

fix: Prevent Cypress from crashing when argument parsing "spec: {}" #18312

Merged
merged 14 commits into from
Oct 5, 2021

Conversation

davidmunechika
Copy link
Contributor

@davidmunechika davidmunechika commented Sep 30, 2021

User facing changelog

When a user attempts to pass {} as an argument to --spec, an error will be thrown indicating the argument could not be parsed since its value was not a string or comma-separated list.

Additional details

Previously, Cypress would crash badly when {} or any other type of object was passed into the --spec argument.
image

This PR improves the robustness of argument parsing to prevent crashing in these situations.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • Has a PR for user-facing changes been opened in cypress-documentation? --> N/A
  • Have API changes been updated in the type definitions? --> N/A
  • Have new configuration options been added to the cypress.schema.json? --> N/A

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 30, 2021

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Sep 30, 2021



Test summary

4204 0 50 2Flakiness 0


Run details

Project cypress
Status Passed
Commit 5ab380e
Started Oct 5, 2021 5:26 PM
Ended Oct 5, 2021 5:36 PM
Duration 09:40 💡
OS Linux Debian - 10.9
Browser Chrome 94

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@davidmunechika davidmunechika marked this pull request as ready for review September 30, 2021 16:45
@davidmunechika davidmunechika requested a review from a team as a code owner September 30, 2021 16:45
@davidmunechika davidmunechika requested review from flotwig and chrisbreiding and removed request for a team September 30, 2021 16:45
@flotwig
Copy link
Contributor

flotwig commented Sep 30, 2021

What is the behavior now if the user passes --spec {}? It should still fail somehow, right?

@davidmunechika
Copy link
Contributor Author

davidmunechika commented Sep 30, 2021

@flotwig I wasn't sure if we wanted to throw an error in this scenario or just accept the object without crashing. Currently, no error is thrown as I am following the behavior that exists if {} were to be passed to other options such as env or reporterOptions. However, if throwing an error is preferred, I can change it.

Screenshot 2021-09-30 at 5 02 23 PM

@jennifer-shehane
Copy link
Member

@davidmunechika --env and --reporterOptions both accept objects normally. The --spec flag has been documented to only accept a string with a spec or a string with a comma-separated list of specs, so that's why passing an object would likely be a situation where one would error instead of silently moving on, because they likely don't understand that it doesn't accept an object. https://on.cypress.io/command-line#cypress-run-spec-lt-spec-gt

This might be an ok fix to have in another PR though rather than this crash fix. It's up to you.

@davidmunechika davidmunechika self-assigned this Oct 4, 2021
@davidmunechika davidmunechika merged commit 56928c8 into develop Oct 5, 2021
@davidmunechika davidmunechika deleted the issue-3957-argument-parsing-crashes branch October 5, 2021 17:31
tgriesser added a commit that referenced this pull request Oct 8, 2021
* develop: (31 commits)
  fix: `everyNthFrame` should only be applied for Chrome 89+ (#18392)
  docs: General updates to contributing guide (#18283)
  chore: Update Chrome (beta) to 95.0.4638.40 (#18389)
  chore: use circleci timings split for e2e tests (#18367)
  fix: fixed title (#18370)
  chore(deps): update dependency electron to v14 🌟 (#18384)
  chore(server): share client route (#18215)
  fix: Prevent Cypress from crashing when argument parsing "spec: {}" (#18312)
  chore: update husky dev dependency to v7 (#18345)
  feat: add defineConfig function to help type config (#18302)
  chore: Update Chrome (stable) to 94.0.4606.71 (#18324)
  feat: allow to use TypeScript in the config file (#18300)
  allow select to be called with empty array (#18329)
  fix(vite-dev-server): windows `supportFile` + preserve optimize entries (#18286)
  chore: fix semantic-release dry run (#18332)
  fix(driver): improve status_code_flags_invalid error message (#18316)
  chore(deps): update dependency electron to v13.5.0 🌟 (#18318)
  chore: Update Chrome (stable) to 94.0.4606.61 and Chrome (beta) to 95.0.4638.32 (#18229)
  fix(proxy-logging): use constant consoleProps object (#18207)
  feat(driver): Add "overwrite" option to cy.screenshot() (#18280)
  ...
tgriesser added a commit that referenced this pull request Oct 8, 2021
* develop: (33 commits)
  fix: remove .json check from require_async, prevent child_process spawn (#18416)
  percy snapshot the tooltip visually, prevent it from being hidden
  fix: `everyNthFrame` should only be applied for Chrome 89+ (#18392)
  docs: General updates to contributing guide (#18283)
  chore: Update Chrome (beta) to 95.0.4638.40 (#18389)
  chore: use circleci timings split for e2e tests (#18367)
  fix: fixed title (#18370)
  chore(deps): update dependency electron to v14 🌟 (#18384)
  chore(server): share client route (#18215)
  fix: Prevent Cypress from crashing when argument parsing "spec: {}" (#18312)
  chore: update husky dev dependency to v7 (#18345)
  feat: add defineConfig function to help type config (#18302)
  chore: Update Chrome (stable) to 94.0.4606.71 (#18324)
  feat: allow to use TypeScript in the config file (#18300)
  allow select to be called with empty array (#18329)
  fix(vite-dev-server): windows `supportFile` + preserve optimize entries (#18286)
  chore: fix semantic-release dry run (#18332)
  fix(driver): improve status_code_flags_invalid error message (#18316)
  chore(deps): update dependency electron to v13.5.0 🌟 (#18318)
  chore: Update Chrome (stable) to 94.0.4606.61 and Chrome (beta) to 95.0.4638.32 (#18229)
  ...
tgriesser added a commit that referenced this pull request Oct 10, 2021
* unified-desktop-gui: (40 commits)
  feat: index.html configurability and storybook support (#18242)
  fix: remove .json check from require_async, prevent child_process spawn (#18416)
  percy snapshot the tooltip visually, prevent it from being hidden
  fix: failing tests from #18372 (#18414)
  fix: `everyNthFrame` should only be applied for Chrome 89+ (#18392)
  feat(app): render spec list, command log, iframe (#18372)
  fix: drag and drop to be correct directory (#18400)
  refactor: Add GitDataSource, FileDataSource, toast for errors (#18385)
  docs: General updates to contributing guide (#18283)
  Add shorter --ct alias for --component
  Add --e2e and --component CLI options
  chore: Update Chrome (beta) to 95.0.4638.40 (#18389)
  chore: use circleci timings split for e2e tests (#18367)
  fix: fixed title (#18370)
  chore(deps): update dependency electron to v14 🌟 (#18384)
  chore(server): share client route (#18215)
  fix: Prevent Cypress from crashing when argument parsing "spec: {}" (#18312)
  chore: update husky dev dependency to v7 (#18345)
  feat: add defineConfig function to help type config (#18302)
  chore: Update Chrome (stable) to 94.0.4606.71 (#18324)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Argument parsing crashes badly if passing "spec: {}"
3 participants