gitlab_project_access_token without expiry cannot be imported

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Collaborate/take over this issue

Bug Report

I cannot import a PAT without expiry Recreate:

  1. Create a gitlab_project_access_token via GUI with NO EXPIRY
  2. Try to import it

Relevant Log Output

 ╷
  │ Error: Plugin did not respond
  │ 
  │ The plugin encountered an error, and failed to respond to the
  │ plugin6.(*GRPCProvider).ReadResource call. The plugin logs may contain more
  │ details.
  ╵
  
  
  Stack trace from the terraform-provider-gitlab_v18.2.0 plugin:
  
  panic: runtime error: invalid memory address or nil pointer dereference
  [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10594b3d8]
  
  goroutine 507 [running]:
  gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider.(*gitlabProjectAccessTokenResource).projectAccessTokenToStateModel(0x14000722378?, {0x105f74768, 0x1400074c5a0}, 0x140006e07e0, 0x1400073e2d0, {0x14000916a50?, 0x1?})
        gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/resource_gitlab_project_access_token.go:238 +0xc8
  gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider.(*gitlabProjectAccessTokenResource).Read(0x140004ed030, {0x105f74768, 0x1400074c5a0}, {{{{0x105f7cdc0, 0x14000713020}, {0x105db50c0, 0x14000712f60}}, {0x105f7fb80, 0x140000f0d70}}, 0x0, ...}, ...)
        gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/resource_gitlab_project_access_token.go:463 +0x530
  github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ReadResource(0x140000fca08, {0x105f74768, 0x1400074c5a0}, 0x14000714190, 0x14000807530)
        github.com/hashicorp/terraform-plugin-framework@v1.15.0/internal/fwserver/server_readresource.go:156 +0x918
  github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ReadResource(0x140000fca08, {0x105f74768?, 0x1400074c4b0?}, 0x14000714050)
        github.com/hashicorp/terraform-plugin-framework@v1.15.0/internal/proto6server/server_readresource.go:71 +0x434
  github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x14000396500, {0x105f74768?, 0x1400074c1e0?}, 0x14000714050)
        github.com/hashicorp/terraform-plugin-mux@v0.20.0/tf6muxserver/mux_server_ReadResource.go:35 +0x17c
  github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0x1400030c460, {0x105f74768?, 0x140007f1350?}, 0x1400025d570)
        github.com/hashicorp/terraform-plugin-go@v0.28.0/tfprotov6/tf6server/server.go:860 +0x210
  github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x105f29600, 0x1400030c460}, {0x105f74768, 0x140007f1350}, 0x14000888c80, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.28.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:651 +0x1c0
  google.golang.org/grpc.(*Server).processUnaryRPC(0x14000274400, {0x105f74768, 0x140007f0c90}, 0x140007a89c0, 0x14000469b60, 0x106740b38, 0x0)
        google.golang.org/grpc@v1.72.1/server.go:1405 +0xc9c
  google.golang.org/grpc.(*Server).handleStream(0x14000274400, {0x105f75410, 0x1400036a4e0}, 0x140007a89c0)
        google.golang.org/grpc@v1.72.1/server.go:1815 +0x900
  google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.72.1/server.go:1035 +0x84
  created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 35
        google.golang.org/grpc@v1.72.1/server.go:1046 +0x138
  
  Error: The terraform-provider-gitlab_v18.2.0 plugin crashed!
  
  This is always indicative of a bug within the plugin. It would be immensely
  helpful if you could report the crash with the plugin's maintainers so that it
  can be fixed. The output above should help diagnose the issue.
  
  
  exit status 1

Additional Details

  • GitLab Terraform Provider Version: 18.2.0
  • GitLab Instance Version: 17.11.6
  • Terraform Version: 1.12.2
  • License Tier: Premium

Implementation plan

To fix this bug, we simply need to update the expires_at and rotation_configuration to both be optional (instead of requiring at least one of the two).

We should also note in our documentation that when neither are provided, the token will default to the instance level expiration status.

Edited Sep 27, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading