Duplicated labels on MRs

Summary

If two automations add labels to a MR ~simultaneously, all labels are added without deduplication (probable race condition).

This notably cause

  • The same label to be present twice;
  • Two scoped labels with the same scope to be present, which should be impossible.

Steps to reproduce

The easiest (only?) way is through the API; example Python code (used for the repro):

import asyncio
import aiohttp

url = "https://gitlab.com/api/v4/projects/77164809/merge_requests/1"
token = "<redacted>"

async def main() -> None:
    async with aiohttp.ClientSession() as session:
        await asyncio.gather(
            session.put(url, json={"add_labels": "some-label,some-scope::a"}, headers={"PRIVATE-TOKEN": token}),
            session.put(url, json={"add_labels": "some-label,some-scope::b"}, headers={"PRIVATE-TOKEN": token}),
        )

asyncio.run(main())

Example Project

Test MR (loic.simon/duplicate-labels-bug-reproducer!1)

What is the current bug behavior?

  • The same label is present twice on the MR
  • Two scoped labels with the same scope are present on the MR

What is the expected correct behavior?

  • Each label is only present one time
  • Only one of the scoped labels is present

Relevant logs and/or screenshots

Screen Shot 2025-12-17 at 11.04.48 AM.png

Screen Shot 2025-12-17 at 11.05.28 AM.png

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Results of GitLab application Check

Possible fixes

Patch release information for backports

If the bug fix needs to be backported in a patch release to a version under the maintenance policy, please follow the steps on the patch release runbook for GitLab engineers.

Refer to the internal "Release Information" dashboard for information about the next patch release, including the targeted versions, expected release date, and current status.

High-severity bug remediation

To remediate high-severity issues requiring an internal release for single-tenant SaaS instances, refer to the internal release process for engineers.

Edited by 🤖 GitLab Bot 🤖