Variables key <key> has already been taken

ZD (internal only): https://gitlab.zendesk.com/agent/tickets/103058

bug:
  1. CI/CD variables cannot be saved with the the same name to different environment. Error Variables key <key> has already been taken when Save variables button clicked multiple times.
  2. Some times (actually quite often) when we try to edit these variables in the Gitlab UI, we get a validation error saying Variables key <key> has already been taken.
Description:

The variables that show up in the error message can differ, sometimes it's all our duplicate variables, sometimes it's just a couple (or even one). I'm able to reproduce this in both Chrome and Firefox locally (latest versions, running on Arch Linux) by just opening the CI/CD variable settings and hitting "Save variables" 2-3 times without changing anything. More often than not, the first 1-2 requests succeed, while the last one fails with the above validation error.

It often works for a colleague of mine when I ask him to perform the changes I need done for me. It somehow seems to be tied to user session or a specific browser/OS combination.

Version affected:

We're running on Gitlab 11.2.3-ee right now, but this issue has been present at least since 11.0 shipped - possibly also before.

Steps to reproduce:
  1. Go to CI/CD varaibles of the project.
  2. Create new environment.
  3. Add Variable to all environemnts.
  4. Add a Variable to the newly created environment with the same name.
  5. Click Save variables button multiple times.
Edited by Julius Kvedaras