Race condition in Project Target Branch Rule GraphQL API

Context where the issue surfaced: terraform-provider-gitlab!2307 (comment 2372121119)

tl;dr: we have an acceptance test in the Terraform Provider that uses the GraphQL API to manage target branch rules. We have a test that asserts an error when a branch rule is added with an already existing name. The two branch rules are created concurrently and we think there is a race condition, because the problem we are seeing is that we don't get that error, instead the rule is created - both rules.

Logs are here: https://gitlab.com/gitlab-org/terraform-provider-gitlab/-/jobs/9272310075/artifacts/browse.

We managed to workaround this in the provider by making sure that the first rule is fully created before the second.


The following discussion from terraform-provider-gitlab!2307 (merged) should be addressed:

  • @timofurrer started a discussion: (+6 comments)

    @kevineor the acceptance test in 17.9.0 is failing: https://gitlab.com/gitlab-org/terraform-provider-gitlab/-/jobs/9272310075#L552

    === NAME  TestAccGitlabProjectTargetBranchRule_DuplicateRule
        resource_gitlab_project_target_branch_rule_test.go:71: Step 1/1, expected an error but got none
Edited Feb 28, 2025 by Timo Furrer
Assignee Loading
Time tracking Loading