Skip to content

Commit 7510959

Browse files
author
Michael Chmielewski
committed
Fix a case where a change to a project in terraform can never apply when certain fields are modified.
Because the gitlab API actually expects at least on field out of a subset of fields in an update call (aside from `id`), if you only modify fields not in this subset, the Gitlab API will return a 400 complaining that one of the needed fields is missing. One of these special fields is `name`. As this seems to be a safe field to assume always exists (we'll still defensively check if nil though), we pass it in always.
1 parent b5a42dd commit 7510959

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/provider/resource_gitlab_project.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,11 @@ func resourceGitlabProjectUpdate(ctx context.Context, d *schema.ResourceData, me
12111211
options := &gitlab.EditProjectOptions{}
12121212
transferOptions := &gitlab.TransferProjectOptions{}
12131213

1214-
if d.HasChange("name") {
1214+
// Always send the name field, to satisfy the requirement of having one
1215+
// of the project attributes listed below in the update call
1216+
// https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/api/helpers/projects_helpers.rb#L120-188
1217+
// if d.HasChange("name") {
1218+
if d.Get("name").(string) != nil {
12151219
options.Name = gitlab.String(d.Get("name").(string))
12161220
}
12171221

0 commit comments

Comments
 (0)