Namespace must be blank error when using gitlab_member_role

I try to create a custom role “security auditor” using the GitLab provider v18.3.0 and gitlab_member_role resource with gitlab.com. When I use group_path = "my-company-namespace" or group_path = data.gitlab_group.top_level_group.full_path the terraform plan command is successful but terraform apply fails with the error:

gitlab_member_role.security_auditor: Creating...
Error: GitLab GraphQL error occurred
  with gitlab_member_role.security_auditor,
  on roles.tf line 5, in resource "gitlab_member_role" "security_auditor":
   5: resource "gitlab_member_role" "security_auditor" {
Error 0 Message: Namespace must be blank 

When I remove the group_path line or use group_path="" the terraform plan fails (as it should according to the documentation) with the message Attribute group_path string length must be at least 1, got: 0:

Implementation Guide

This bug is caused because READ_ADMIN_CICD isn't available on SaaS (I.e., when the associated client has a base URL of https://gitlab.com).

Since the client isn't initialized during the ValidateConfig phase, we'll need to handle this validation during the ModifyPlan phase instead. This issue should add or update the ModifyPlan function to check the baseURL of the client, and if it's SaaS, then check if the READ_ADMIN_CICD is present, and return an error diagnostic if it is.

Edited by 🤖 GitLab Bot 🤖