Plugin did not respond when adding an additional gitlab_integration_github.github_integration to import
Bug Report
This bugs happens only after a successful initial plan/apply of the terraform code.
The simplified structure of the terraform is:
- Creates a gitlab_integration_github.github_integration through a module call
- Conditonnaly import a gitlab_integration_github.github_integration if exists through an import block
This works the first time around, and imports to state. If the input is modified with a new resource to import (and only import, create only does not raise this bug), the the error below happens. Will sanitize logs and upload shortly
Simplified structure:
locals: {
importable_projects = { for k, v in local.replication_map : k => v if lookup(v, "to_import", false) }
replication_map = {
"gh_group1/gh_repo1" = {
gl_group = "gl_group1"
gl_project = "gl_project1"
to_import = true
}
"gh_group1/gh_repo2" = {
gl_group = "gl_group1"
gl_project = "gl_project2"
to_import = true
}
"gh_group1/gh_repo3" = {
gl_group = "gl_group1"
gl_project = "gl_project3"
to_import = true
}
}
github_integration_ids = {
for k, v in data.http.github_integrations :
k => jsondecode(v.response_body)
if !(can(jsondecode(v.response_body).message == "404 Integration Not Found")) # Filter out non-existant
}
}
# Import Gitlab Integration, if found
module "gitlab_github_integration" {
source = "git::https://[redacted]/[redacted]/terraform-gitlab-github_integration?ref=v1.0.0"
for_each = { for k, v in local.replication_map : k => v }
github_token = module.github_token.variable_value
gitlab_project_id = module.gitlab_project[each.key].project_id
github_org_repo = each.key
}
module "gitlab_project" {
source = "git::[redacted]/[redacted]/terraform-gitlab-project?ref=v1.1.0"
for_each = { for k, v in local.replication_map : k => v }
github_repository_name = each.key
gitlab_group_name = each.value.gl_group
gitlab_project_name = each.value.gl_project
github_token = module.github_token.variable_value
import_project = lookup(each.value, "import_project", false)
token_rotate_before = 80
}
import {
for_each = { for k, v in local.importable_projects : k => v if contains(keys(local.github_integration_ids), k) }
to = module.gitlab_github_integration[each.key].gitlab_integration_github.github_integration
id = local.github_integration_ids[each.key].id
}
import {
for_each = { for k, v in local.importable_projects : k => v }
to = module.gitlab_project[each.key].gitlab_project.mirror_project
id = data.gitlab_project.gitlab_project_ref[each.key].id
}
data "http" "github_integrations" { # There is no data source for Github integrations, so we need to use the HTTP provider
for_each = local.importable_projects # Only import if the project is marked as importable
url = "${local.gitlab_api}projects/${data.gitlab_project.gitlab_project_ref[each.key].id}/integrations/github"
request_headers = {
"PRIVATE-TOKEN" = var.gitlab_token
}
}
data "gitlab_project" "gitlab_project_ref" {
for_each = local.importable_projects # Only import if the project is marked as importable
path_with_namespace = join("/", [each.value.gl_group, each.value.gl_project])
}
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.
╵
╷
│ 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.
╵
╷
│ 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.
╵
╷
│ 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_v17.5.0 plugin:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xd7f133]
goroutine 369 [running]:
gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/sdk.resourceGitlabIntegrationGithubRead({0x1381b30, 0xc00021ea10}, 0xc00062e500, {0x10f1d80?, 0xc0002aa508})
gitlab.com/gitlab-org/terraform-provider-gitlab/internal/provider/sdk/resource_gitlab_integration_github.go:139 +0x273
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0004121c0, {0x1381a88, 0xc000825950}, 0xc00062e500, {0x10f1d80, 0xc0002aa508})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:823 +0x119
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0004121c0, {0x1381a88, 0xc000825950}, 0xc000378ea0, {0x10f1d80, 0xc0002aa508})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:1117 +0x525
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000011878, {0x1381a88?, 0xc000825830?}, 0xc000b8eb80)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:708 +0x6a5
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x138ddb8?, 0xc000011878?}}, {0x1381a88?, 0xc000825830?}, 0xc000b8ea80?)
github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:153 +0x2ab
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0xc000269880, {0x1381a88?, 0xc000825560?}, 0xc000b8ea80)
github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_ReadResource.go:35 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc000263b80, {0x1381a88?, 0xc000824d80?}, 0xc00021e3f0)
github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov6/tf6server/server.go:784 +0x2f3
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x114b180, 0xc000263b80}, {0x1381a88, 0xc000824d80}, 0xc00062e200, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:509 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000193000, {0x1381a88, 0xc000824cf0}, {0x1389340, 0xc00044c340}, 0xc0009138c0, 0xc0004eb560, 0x1a961a8, 0x0)
google.golang.org/grpc@v1.66.2/server.go:1394 +0xe2b
google.golang.org/grpc.(*Server).handleStream(0xc000193000, {0x1389340, 0xc00044c340}, 0xc0009138c0)
google.golang.org/grpc@v1.66.2/server.go:1805 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
google.golang.org/grpc@v1.66.2/server.go:1029 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 16
google.golang.org/grpc@v1.66.2/server.go:1040 +0x125
Error: The terraform-provider-gitlab_v17.5.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.
Relevant Terraform Configuration
Config:
terraform {
backend "http" {
}
required_providers {
gitlab = {
source = "gitlabhq/gitlab"
version = "~> 17.5.0"
}
github = {
source = "integrations/github"
version = "6.3.1"
}
}
}
provider "gitlab" {
base_url = local.gitlab_api
token = var.gitlab_token
}
provider "http" {
}
Relevant Terraform Command
terraform plan
Relevant Log Output
These are the debug logs of the `terraform` command output:
Additional Details
- GitLab Terraform Provider Version:
17.5.0 - GitLab Version:
17.5.3 - Terraform Version:
v1.9.5
Edited by espege