DopplerHQ / DopplerHQ/cli

[BUG] Race condition in `doppler setup` when applying settings in more than one project

Open
#403 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Go
Stars
396
Forks
83
Avg merge
1d 2h
Merged PRs (30d)
3

Description

Describe the bug
If you run doppler setup in two or more projects at once, they will open the user's doppler config ~/.doppler/.doppler.yaml at the same time and apply their changes to the same copy of the file, resulting in only one of the changes applying. This might occur if the user batches changes across several projects with doppler setup --no-interactive.

To Reproduce

  1. Set up two or more directories with a doppler.yaml
  2. Execute the following in the parent directory of those two:
parallel "cd {} && doppler setup --no-interactive --debug" ::: *
  1. Check doppler configure in any of the projects, observing that one of the projects has a project and config in its configure, but the others do not
  2. Check ~/.doppler/.doppler.yaml to confirm the same

Example of this occurring:

~/example ❯ parallel "cd {} && doppler setup --no-interactive --debug" ::: *
Auto-selecting project from repo config file
Auto-selecting config from repo config file
┌─────────┬────────┬──────────────────────────────────┐
│ NAME    │ VALUE  │ SCOPE                            │
├─────────┼────────┼──────────────────────────────────┤
│ config  │ prd    │ /home/gregdan3/example/project_2 │
│ project │ common │ /home/gregdan3/example/project_2 │
└─────────┴────────┴──────────────────────────────────┘
Debug: Using config dir /home/gregdan3/.doppler
Debug: Using config file /home/gregdan3/.doppler/.doppler.yaml
Debug: Reading config file
Debug: Reading repo config file doppler.yaml
Debug: Sending anonymous analytics payload: '{"command":"doppler.setup"}'
Debug: Performing HTTP POST to https://cli.doppler.com/v1/analytics
Debug: Writing user config to /home/gregdan3/.doppler/.doppler.yaml
Debug: Writing to temp file /home/gregdan3/.doppler/.doppler.yaml.Q5xDAKWw
Debug: Renaming temp file to /home/gregdan3/.doppler/.doppler.yaml
Auto-selecting project from repo config file
Auto-selecting config from repo config file
┌─────────┬────────┬──────────────────────────────────┐
│ NAME    │ VALUE  │ SCOPE                            │
├─────────┼────────┼──────────────────────────────────┤
│ config  │ prd    │ /home/gregdan3/example/project_1 │
│ project │ common │ /home/gregdan3/example/project_1 │
└─────────┴────────┴──────────────────────────────────┘
Debug: Using config dir /home/gregdan3/.doppler
Debug: Using config file /home/gregdan3/.doppler/.doppler.yaml
Debug: Reading config file
Debug: Reading repo config file doppler.yaml
Debug: Sending anonymous analytics payload: '{"command":"doppler.setup"}'
Debug: Performing HTTP POST to https://cli.doppler.com/v1/analytics
Debug: Writing user config to /home/gregdan3/.doppler/.doppler.yaml
Debug: Writing to temp file /home/gregdan3/.doppler/.doppler.yaml.5QZbeO6Y
Debug: Renaming temp file to /home/gregdan3/.doppler/.doppler.yaml

Expected behavior
Doppler should keep track of a lockfile so the config file can only be read and written to by one process at a time.

Desktop (please complete the following information):

  • OS: Archlinux
  • Version 6.3.4-arch2-1
  • uname --all: Linux ilo 6.3.4-arch2-1 #1 SMP PREEMPT_DYNAMIC Mon, 29 May 2023 13:58:34 +0000 x86_64 GNU/Linux

CLI Version:
Version v3.60.1

Additional context
Feel free to let me know if this a harebrained activity that doesn't need fixing- for the time being we'll be working around this by dispatching setup commands consecutively rather than simultaneously anyway.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the doppler setup path and the code that reads and writes ~/.doppler/.doppler.yaml; use the concurrent parallel reproduction to observe the lost update. Check how doppler configure reads the resulting settings. Done means concurrent setup processes serialize access so every project's project and config settings remain in the user config file.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.