gitlab_group - name value with "," succeeds on plan but fails on apply
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Bug Report
When declaring a gitlab_group resource with a faulty name the tf plan succeeds but the tf apply fails with the follwoing error:
name=>["can contain only letters, digits, emoji, '_', '.', dash, space, parenthesis. It must start with letter, digit, emoji or '_'."
The expected behavior is that the tf plan (also) fails if the name attribute is not correct.
Relevant Terraform Configuration
resource "gitlab_group" "gitlab_group_example" {
name = " Gitlab Group Example, Issue Example"
path = "gitlab-group-example"
}
The starting with a space and having a , in the name is not allowed
Relevant Terraform Command
Output of tf plan (abbreviated for readability):
Terraform will perform the following actions:
# gitlab_group.gitlab_group_example will be created
+ resource "gitlab_group" "gitlab_group_example" {
...................
+ name = " Gitlab Group Example, Issue Example"
+ parent_id = (known after apply)
+ path = "gitlab-group-example"
+ permanently_remove_on_delete = false
...................
}
Plan: 1 to add, 0 to change, 0 to destroy.
The name attribute clearly has an illegal value but plan succeeds
Output of tf apply:
gitlab_group.gitlab_group_example: Creating...
╷
│ Error: POST https://gitlab.com/api/v4/groups: 400 {message: Failed to save group {:name=>["can contain only letters, digits, emoji, '_', '.', dash, space, parenthesis. It must start with letter, digit, emoji or '_'."]}}
│
│ with gitlab_group.gitlab_group_example,
│ on main.tf line 88, in resource "gitlab_group" "gitlab_group_example":
│ 88: resource "gitlab_group" "gitlab_group_example" {
│
╵
Additional Details
- GitLab Terraform Provider Version: `18.4.1`
- Terraform Version: `1.13.4`
- License Tier:
Premium
Implementation Guide
- Ensure you have set up your local development environment as described in
CONTRIBUTING.mdand you have cloned the community fork of the provider. - Add a
ValidateFuncto gitlab_group.name ensuring it matches a regular expression as described in the error message above (can contain only letters, digits, emoji, '', '.', dash, space, parenthesis. It must start with letter, digit, emoji or ''). - Add an integration test to https://gitlab.com/gitlab-org/terraform-provider-gitlab/-/blob/main/internal/provider/sdk/resource_gitlab_group_test.go to check the validation rejects invalid names.
Edited by 🤖 GitLab Bot 🤖