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

Record is not reading env variable set in cypress.json or cypress.env.json #938

Closed
dthisner opened this issue Nov 20, 2017 · 11 comments
Closed

Comments

@dthisner
Copy link

dthisner commented Nov 20, 2017

Current behavior:

Not able to run the cypress run --record command without a flag, when storing the key as an ENV variable

It works exporting the variable first and then run the cypress run --record

Desired behavior:

Being able to store env variable

How to reproduce:

  1. Set env as following in: cypress.json

{ "projectId": "1280ayu", "env": { "cypress_record_key": "88897382" } }
CYPRESS_RECORD_KEY or RECORD_KEY or record_key
2. run: cypress run --record
3. Issue occurs: User gets error:


You can pass us your Record Key like this:

  cypress run --record --key <record_key>

You can also set the key as an environment variable with the name CYPRESS_RECORD_KEY.

https://on.cypress.io/how-do-i-record-runs

Same thing happens if user tries to store it in: cypress.env.json

Test code:

Additional Info (images, stack traces, etc)

  • Operating System: Ubuntu
  • Cypress Version: 1.0.3
  • Browser Version: Chrome 61
@brian-mann
Copy link
Member

I wouldn't say this was a bug. record_key wouldn't be the correct value of it anyway - it would just be key. Why is this necessary? You typically wouldn't set this value in something that's under source control unless this is a private project and you never expect to change the record key.

Usually best practices for secrets are always something done empeherally.

@dthisner
Copy link
Author

I added that I also tried: CYPRESS_RECORD_KEY or RECORD_KEY or record_key, which none of them worked

@brian-mann
Copy link
Member

I understand. We handle the record key different than other environment variables. My question is still from before - this key is secret and sensitive. Why check it into a static file that's version controlled?

@dthisner
Copy link
Author

Because the documentation said I could =) no other reason really

@brian-mann
Copy link
Member

Where does the documentation say that?

@dthisner
Copy link
Author

@jennifer-shehane
Copy link
Member

Well, the docs certainly don't say that you can't pass a record key like any other environment variable. It appears like it should work this way (whether it's advisable or not)

@brian-mann
Copy link
Member

Okay I see the source of confusion - but I'd rather err on the side of not supporting this. It would be easy to do so - but this is a secret key that should not be written alongside of your other environment variables.

It would be easy enough for you to choose to embed it somewhere in your npm scripts or a script you write using the Cypress Module API, but I wouldn't recommend it being in cypress.json or cypress.env.json. It's only useful when choosing to record to the Dashboard, which is typically only run in CI. In those situations using CI based environment variables, or adding it directly to the cypress run command would be advisable.

I would be open to changing this if a more compelling use case could be justifed.

@donaldshen
Copy link

donaldshen commented Feb 6, 2020

Okay I see the source of confusion - but I'd rather err on the side of not supporting this. It would be easy to do so - but this is a secret key that should not be written alongside of your other environment variables.

It would be easy enough for you to choose to embed it somewhere in your npm scripts or a script you write using the Cypress Module API, but I wouldn't recommend it being in cypress.json or cypress.env.json. It's only useful when choosing to record to the Dashboard, which is typically only run in CI. In those situations using CI based environment variables, or adding it directly to the cypress run command would be advisable.

I would be open to changing this if a more compelling use case could be justifed.

https://docs.cypress.io/guides/guides/environment-variables.html#Option-2-cypress-env-json

I would like to manage record key in cypress.env.json and gitignore the file, rather than export it in local bash_profile, as this doc suggests.

@kfriars
Copy link

kfriars commented Feb 17, 2020

Agreed. I would also like to manage it from cypress.env.json and .gitignore it.

You shouldn't be checking environment variables into source control almost by definition. If someone has access to reading the contents of your .env file hosted in your environment, them knowing your record key is probably the least of your problems.

@jennifer-shehane
Copy link
Member

@donaldshen @kfriars Please open a new issue detailing exactly what and why you want this feature request. 2+ yr old issues are not the place to ask for feature requests.

@cypress-io cypress-io locked and limited conversation to collaborators Feb 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants