Scheduled pipelines with no owner crashes the provider
Bug Report
When a terraform-managed scheduled pipeline (https://registry.terraform.io/providers/gitlabhq/gitlab/16.6.0/docs/resources/pipeline_schedule) lose their owner, future terraform plans crash with
Stack trace from the terraform-provider-gitlab_v16.6.0 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xcbbf25]
goroutine 339 [running]:
gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/sdk.resourceGitlabPipelineScheduleRead({0x11e77b8?, 0xc000260000}, 0xc000054c00, {0xfa46c0?, 0xc000190000})
gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/sdk/resource_gitlab_pipeline_schedule.go:187 +0x625
In our case, the reason for the error is simple, but requires manual intervention on GitLab to assign an owner before retrying the Terraform plan.
1- Create a group access token
2- Use this newly created group access token as credentials on a different terraform project that creates a schedule pipeline
3- Wipe the group access token and create a new one
4- Repeat step 2
What is probably happening is that when the group access token is removed all their owned scheduled pipelines become orphans. And https://gitlab.com/gitlab-org/terraform-provider-gitlab/-/blob/v16.6.0/internal/provider/sdk/resource_gitlab_pipeline_schedule.go?ref_type=tags#L187 pipelineSchedule.Owner
(https://github.com/xanzy/go-gitlab/blob/main/pipeline_schedules.go#L47) is a pointer to nil that of course blows when we try to access to pipelineSchedule.Owner.ID
Relevant Terraform Configuration
Not relevant
Relevant Terraform Command
Not relevant
Relevant Log Output
These are the debug logs of the `terraform` command output:
Additional Details
- GitLab Terraform Provider Version:
16.6.0
- GitLab Version:
16.4.2-ee
- Terraform Version:
1.6.3