DopplerHQ / cli

The official CLI for interacting with your Doppler secrets and configuration.
https://docs.doppler.com
Apache License 2.0
218 stars 44 forks source link

doppler run no longer overrides local environment variables #307

Closed matthewtole closed 2 years ago

matthewtole commented 2 years ago

Describe the bug

If you have an environment variable that matches a Doppler variable, using doppler run will choose the environment variable, not the Doppler one, even if you don't use the --preserve-env flag.

This is a regression introduced in 3.39.0

To Reproduce

  1. Set an environment variable locally that has the same name as one in Doppler.
  2. Use doppler run node and then log the environment variable
  3. It will log the value from your local environment

Expected behavior

It should log the value from Doppler.

CLI Version: 3.39.0

matthewtole commented 2 years ago

I'm not a Go expert, but I believe this line is the problem:

https://github.com/DopplerHQ/cli/blob/master/pkg/cmd/run.go#L225

The original environment is being appended to the new environment, which will overwrite any matching values in the environment.

Piccirello commented 2 years ago

Thanks for reporting this bug. We're currently investigating and will report back.

Piccirello commented 2 years ago

I've confirmed this issue and put up a fix. This change should ship tomorrow, May 6th, in v3.19.1. I've also added some tests to ensure this doesn't break again in the future.

Piccirello commented 2 years ago

v3.19.1 is now live with this fix. Apologies for the inconvenience.