Terraform plan sometimes fail but re-running works

Bug Report

I noticed that when making updates, sometimes gitlab apis return 400.

Error: POST https:///api/v4/groups: 400 {message: Failed to save group {:name=>[“has already been taken”], :path=>[“has already been taken”]}}

with gitlab_group.groups[“17”], on main.tf line 23, in resource “gitlab_group” “groups”: 23: resource “gitlab_group” “groups” {

After a few minutes, when I re-run terraform plan , it works. My theory is that there is some delay before the state of the apis are in sync. Is there a way to automate this?

Relevant Terraform Configuration

locals {
  yaml_teams = yamldecode(file("teams.yml"))
}

data "gitlab_group" "people" {
  group_id = 1
}

resource "gitlab_group" "groups" {
  for_each = { for idx, team in local.yaml_teams : idx => team }
  // noinspection HILUnresolvedReference
  name      = each.value.team
  parent_id = data.gitlab_group.people.group_id
  // noinspection HILUnresolvedReference
  path                   = each.value.team
  project_creation_level = "noone"
  request_access_enabled = false
  visibility_level       = "internal"
}

Relevant Terraform Command

terraform plan

Relevant Log Output

sorry I don't have the log file

Additional Details

  • GitLab Terraform Provider Version: 16.11.0``
  • GitLab Version: GitLab Enterprise Edition v16.1.6-ee``
  • Terraform Version: 1.5``
Edited by Theodore Gonzalez