gitlab_release: apply fails without ref, and plan fails once the release is deleted outside of Terraform
Bug Report
gitlab_release has two bugs:
- Apply fails when
refis not set.refis optional and computed (schema), but the releases API never returns it (BasicReleaseDetails) andreleaseModelToStatenever sets it. A release for an existing tag needs noref, but without it the value stays unknown and the apply fails, after GitLab has created the release. An update withoutreffails the same way. - Plan fails after the release is deleted outside of Terraform.
Readreturns the 404 as an error instead of removing the release from the state, so every plan fails untilterraform state rm.Deletefails too, soterraform destroy -refresh=falsedoes: GitLab answers the deletion of a missing release with 403, since it authorizes against the release before looking for it.
Expected: an unset ref is null in the state, and a release deleted outside of Terraform is planned for creation again.
Relevant Terraform Configuration
resource "gitlab_release" "this" {
project = "<project id>"
tag_name = "<a tag that already exists>"
}Relevant Terraform Command
terraform apply
# second bug: with ref set, apply, delete the release in GitLab, then
terraform planRelevant Log Output
Acceptance tests for both cases against GitLab CE 19.5.0, provider at dba01c37
Error: Provider returned invalid result object after apply
After the apply operation, the provider still indicated an unknown value for
gitlab_release.this.ref. All values must be known after apply, so this is
always a bug in the provider and should be reported in the provider's own
repository. Terraform will still save the other known object values in the
state.Error: GitLab API error occurred
with gitlab_release.this,
on terraform_plugin_test.tf line 12, in resource "gitlab_release" "this":
12: resource "gitlab_release" "this" {
Unable to get a release: 404 Not FoundError: GitLab API error occurred
Unable to delete a release: DELETE
http://gitlab/api/v4/projects/51/releases/v1%2E0%2E0: 403 {message:
403 Forbidden}Additional Details
- GitLab Terraform Provider Version:
mainatdba01c37 - GitLab Instance Version:
19.5.0(CE) - Terraform Version:
1.4.0 - License Tier:
Free
I have a fix with acceptance tests ready and would like to work on this.
Edited by 🤖 GitLab Bot 🤖