panic: runtime error: invalid memory address or nil pointer dereference for gitlab_system_hook
I get the `nil` reference for gitlab_system_hook ``` GitLab version v18.11.1-ee Terraform v1.15.2 on linux_amd64 + provider registry.terraform.io/gitlabhq/gitlab v19.0.0 + provider registry.terraform.io/hashicorp/aws v6.46.0 + provider registry.terraform.io/hashicorp/time v0.14.0 + provider registry.terraform.io/hashicorp/tls v4.3.0 + provider registry.terraform.io/rossumai/secret v1.2.1 ``` Code snippet ``` resource "gitlab_system_hook" "lambda" { url = "https://REDACTED.lambda-url.eu-west-1.on.aws/" enable_ssl_verification = true merge_requests_events = true push_events = false tag_push_events = false repository_update_events = false } ``` alternative code snippet (the same result) ``` resource "gitlab_system_hook" "lambda" { url = "https://REDACTED.lambda-url.eu-west-1.on.aws/" enable_ssl_verification = true } ``` ``` │ Error: Request cancelled │ │ The plugin6.(*GRPCProvider).ApplyResourceChange request was cancelled. ╵ Stack trace from the terraform-provider-gitlab_v19.0.0 plugin: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1503a22] goroutine 32 [running]: gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider.(*gitlabSystemHookResource).Create(0x1fa3b2d181b8, {0x1b5fda8, 0x1fa3b340f0b0}, {{{{0x1b707e0, 0x1fa3b2b70060}, {0x17def20, 0x1fa3b340fc80}}, {0x1b86218, 0x1fa3b2eca500}}, {{{0x1b707e0, ...}, ...}, ...}, ...}, ...) gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/resource_gitlab_system_hook.go:163 +0x762 github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).CreateResource(0x1fa3b3036388, {0x1b5fda8, 0x1fa3b340f0b0}, 0x1fa3b2c5b438, 0x1fa3b2c5b408) github.com/hashicorp/terraform-plugin-framework@v1.19.0/internal/fwserver/server_createresource.go:127 +0x8e2 github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0x1fa3b3036388, {0x1b5fda8, 0x1fa3b340f0b0}, 0x1fa3b2e3e2a0, 0x1fa3b2c5b590) github.com/hashicorp/terraform-plugin-framework@v1.19.0/internal/fwserver/server_applyresourcechange.go:63 +0x535 github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0x1fa3b3036388, {0x1b5fda8?, 0x1fa3b340efc0?}, 0x1fa3b340a410) github.com/hashicorp/terraform-plugin-framework@v1.19.0/internal/proto6server/server_applyresourcechange.go:71 +0x5f4 github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x1fa3b2f46990, {0x1b5fda8?, 0x1fa3b340ecf0?}, 0x1fa3b340a410) github.com/hashicorp/terraform-plugin-mux@v0.23.1/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x18d github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x1fa3b2f5a320, {0x1b5fda8?, 0x1fa3b340e210?}, 0x1fa3b2ed2200) github.com/hashicorp/terraform-plugin-go@v0.31.0/tfprotov6/tf6server/server.go:945 +0x3b9 github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x1a165c0, 0x1fa3b2f5a320}, {0x1b5fda8, 0x1fa3b340e210}, 0x1fa3b2ed2100, 0x0) github.com/hashicorp/terraform-plugin-go@v0.31.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:961 +0x1a6 google.golang.org/grpc.(*Server).processUnaryRPC(0x1fa3b2f446c8, {0x1b5fda8, 0x1fa3b340e180}, 0x1fa3b3000000, 0x1fa3b2d77950, 0x2a5c9c8, 0x0) google.golang.org/grpc@v1.81.1/server.go:1430 +0x11dc google.golang.org/grpc.(*Server).handleStream(0x1fa3b2f446c8, {0x1b60b98, 0x1fa3b2d80000}, 0x1fa3b3000000) google.golang.org/grpc@v1.81.1/server.go:1856 +0xbc6 google.golang.org/grpc.(*Server).serveStreams.func2.1() google.golang.org/grpc@v1.81.1/server.go:1065 +0x7f created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 9 google.golang.org/grpc@v1.81.1/server.go:1076 +0x11d Error: The terraform-provider-gitlab_v19.0.0 plugin crashed! ``` ## Implementation Guide - Follow the `CONTRIBUTING.md` guide for setting up your local development environment. - Clone the community fork of this project. - In `internal/provider/resource_gitlab_system_hook.go`, in the `Create` function after the API call, amend the logic where it attempts to set the `Token` attribute into the state model. If the value is non-nil/non-unknown set it in the model, otherwise set it to `types.StringNull`. - Add a new test case to `internal/provider/resource_gitlab_system_hook_test.go` which creates a system hook without setting the `token` attribute.
issue