SIGSEGV when updating expires_at from a new time_offset resource

Bug Report

Stack trace from the terraform-provider-gitlab_v17.0.0 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xe11051]
goroutine 386 [running]:
gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider.(*gitlabProjectAccessTokenResource).ModifyPlan(0xc00040d3a8, {0x129e4c8, 0xc00021de90}, {{{{0x12a4080, 0xc00027f350}, {0xf32a20, 0xc00027f020}}, {0x12a63b0, 0xc00067d180}}, {{{0x12a4080, ...}, ...}, ...}, ...}, ...)
	gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/resource_gitlab_project_access_token.go:336 +0xcd1
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).PlanResourceChange(0xc0003ec340, {0x129e4c8, 0xc00021de90}, 0xc0005fb720, 0xc0006435d0)
	github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/fwserver/server_planresourcechange.go:281 +0x1696
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).PlanResourceChange(0xc0003ec340, {0x129e4c8?, 0xc00021dd70?}, 0xc0005fb680)
	github.com/hashicorp/terraform-plugin-framework@v1.8.0/internal/proto6server/server_planresourcechange.go:55 +0x39c
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).PlanResourceChange(0xc00023f810, {0x129e4c8?, 0xc00021daa0?}, 0xc0005fb680)
	github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_PlanResourceChange.go:73 +0x2ad
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).PlanResourceChange(0xc000234780, {0x129e4c8?, 0xc00021d290?}, 0xc0004eec00)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:825 +0x3f0
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_PlanResourceChange_Handler({0x1087a20, 0xc000234780}, {0x129e4c8, 0xc00021d290}, 0xc0004eeb80, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:500 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00019ce00, {0x129e4c8, 0xc00021d200}, {0x12a4d60, 0xc0002e4300}, 0xc000405c20, 0xc000486cc0, 0x1952860, 0x0)
	google.golang.org/grpc@v1.63.2/server.go:1369 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc00019ce00, {0x12a4d60, 0xc0002e4300}, 0xc000405c20)
	google.golang.org/grpc@v1.63.2/server.go:1780 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 8
	google.golang.org/grpc@v1.63.2/server.go:1030 +0x125
Error: The terraform-provider-gitlab_v17.0.0 plugin crashed!

Relevant Terraform Configuration

terraform {
  required_providers {
    gitlab = {
      source  = "gitlabhq/gitlab"
      version = "17.0.0"
    }
  }
}

variable "gitlab_token" {
  type = string
  sensitive = true
}

provider "gitlab" {
  token    = var.gitlab_token
  base_url = "https://gitlab.com/api/v4"
}

resource "time_offset" "year" {
  offset_days = 364
}

resource "gitlab_project_access_token" "token" {
  project      = 58586280
  name         = "token"
  expires_at   = split("T", time_offset.year.rfc3339)[0]
  access_level = "developer"
  scopes       = ["read_api"]
}

Relevant Terraform Command

terraform init
terraform apply --auto-approve
terraform taint time_offset.year # this could also be triggered by using a time_rotating resource
terraform apply/plan/destroy # this fails

Relevant Log Output

These are the debug logs of the `terraform` command output:

Additional Details

  • GitLab Terraform Provider Version: 17.0.0
  • GitLab Version: 17.1.0-pre 899f3f3916f (.com)
  • Terraform Version: 1.5.7
Edited by Niklas van Schrick