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

Users might pass arguments using CLI flag=value #8874

Closed
bahmutov opened this issue Oct 16, 2020 · 7 comments · Fixed by #8935
Closed

Users might pass arguments using CLI flag=value #8874

bahmutov opened this issue Oct 16, 2020 · 7 comments · Fixed by #8935
Assignees
Labels
cli good first issue Good for newcomers topic: parallelization type: unexpected behavior User expected result, but got another

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Oct 16, 2020

From Gitter https://gitter.im/cypress-io/cypress?at=5f8a04b73d172d78b37c71ba

Weird that it converts the value to Infinity?!

@bahmutov bahmutov added cli topic: parallelization type: unexpected behavior User expected result, but got another labels Oct 16, 2020
@jennifer-shehane
Copy link
Member

It’s because the ID they’re passing evaluates to a number instead of a string, due to the e exponential notation. See #6891

@jennifer-shehane jennifer-shehane added good first issue Good for newcomers stage: ready for work The issue is reproducible and in scope internal-priority labels Oct 18, 2020
@bahmutov bahmutov self-assigned this Oct 22, 2020
@bahmutov
Copy link
Contributor Author

Looking at an existing project:

DEBUG=cypress:cli npx cypress run --record --ci-build-id 10e100
  cypress:cli spawning Cypress with executable: /Users/gleb/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/MacOS/Cypress +4ms
  cypress:cli spawn args [ '--no-sandbox', '--', '--run-project', '/Users/gleb/git/cypress-test-tiny', '--ci-build-id', '10e100', '--record', true, '--cwd', '/Users/gleb/git/cypress-test-tiny' ] { detached: false, stdio: [ 'inherit', 'inherit', 'pipe' ] }

So the CLI does not convert the build id, just passes it as a string

@bahmutov
Copy link
Contributor Author

Looking at all logs with DEBUG=cypress:* npx cypress run --record --ci-build-id 10e100 shows were we cast the build id into a string

  cypress:server:cypress starting cypress with argv [ '/Users/gleb/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--', '--run-project', '/Users/gleb/git/cypress-test-tiny', '--ci-build-id', '10e100', '--record', 'true', '--cwd', '/Users/gleb/git/cypress-test-tiny' ] +0ms
  cypress:server:args argv array: [ '/Users/gleb/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/MacOS/Cypress', '--no-sandbox', '--run-project', '/Users/gleb/git/cypress-test-tiny', '--ci-build-id', '10e100', '--record', 'true', '--cwd', '/Users/gleb/git/cypress-test-tiny' ] +0ms
  cypress:server:args argv parsed: { _: [ '/Users/gleb/Library/Caches/Cypress/5.4.0/Cypress.app/Contents/MacOS/Cypress' ], sandbox: false, runProject: '/Users/gleb/git/cypress-test-tiny', ciBuildId: 1e+101, record: true, cwd: '/Users/gleb/git/cypress-test-tiny', invokedFromCli: true } +3ms

@bahmutov
Copy link
Contributor Author

in packages/server/lib/util/args.js

options = _
  .chain(options)
  .defaults(allowed)
  .omit(_.keys(alias)) // remove aliases
  .extend({ invokedFromCli })
  .defaults({
    // set in case we
    // bypassed the cli
    cwd: process.cwd(),
  })
  .mapValues(coerceUtil)
  .value()

debug('argv parsed: %o', options)

@bahmutov
Copy link
Contributor Author

Taking a debug log before it

debug('argv array: %o', argv)
let options = minimist(argv, {
  alias,
})
debug('argv options %o', { options })

Shows the problem is minimist casting the argument

  cypress:server:cypress starting cypress with argv [ '/Users/gleb/.nvm/versions/node/v12.14.1/bin/node', '/Users/gleb/git/cypress/scripts/start.js', '--runProject', '/Users/gleb/git/cypress-test-tiny', '--record', '--ci-build-id', '10e100' ] +0ms
  cypress:server:args argv array: [ '/Users/gleb/.nvm/versions/node/v12.14.1/bin/node', '/Users/gleb/git/cypress/scripts/start.js', '--runProject', '/Users/gleb/git/cypress-test-tiny', '--record', '--ci-build-id', '10e100' ] +0ms
  cypress:server:args argv options { options: { _: [ '/Users/gleb/.nvm/versions/node/v12.14.1/bin/node', '/Users/gleb/git/cypress/scripts/start.js' ], runProject: '/Users/gleb/git/cypress-test-tiny', 'run-project': '/Users/gleb/git/cypress-test-tiny', record: true, 'ci-build-id': 1e+101, ciBuildId: 1e+101 } } +1ms

@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 Oct 22, 2020
@sync-by-unito sync-by-unito bot assigned jennifer-shehane and unassigned bahmutov Oct 23, 2020
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 23, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2020

The code for this is done in cypress-io/cypress#8935, 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 Oct 27, 2020

Released in 5.5.0.

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

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Oct 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli good first issue Good for newcomers topic: parallelization type: unexpected behavior User expected result, but got another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants