microsoft / terraform-provider-azuredevops

Terraform Azure DevOps provider
https://www.terraform.io/docs/providers/azuredevops/
MIT License
372 stars 260 forks source link

Error: The terraform-provider-azuredevops_v1.0.1 plugin crashed! #1009

Closed callumhester closed 3 months ago

callumhester commented 3 months ago

Community Note

Terraform (and Azure DevOps Provider) Version

Terraform Version: 1.7.5 Azure DevOps Provider Version: 1.0.1

Affected Resource(s)

azuredevops_project azuredevops_project_features azuredevops_group_entitlement azuredevops_group_membership data.azuredevops_group azuredevops_iteration_permissions azuredevops_area_permissions

Terraform Configuration Files

terraform {
  required_version = ">= __terraform_required_version__"
  required_providers {
    azuredevops = {
      source = "microsoft/azuredevops"
      version = "__terraform_ado_version__"
    }
  }
}
resource "azuredevops_project" "project" {
  name        = var.project_name
  description = var.project_description
  work_item_template = "Scrum"
}
resource "azuredevops_project_features" "project" {
  project_id = var.project_id
  features = {
    "boards"       = var.project_type != "squad" ? "disabled" : "enabled"
    "repositories" = var.project_type != "team" ? "disabled" : "enabled"
    "pipelines"    = var.project_type != "team" ? "disabled" : "enabled"
    "testplans"    = var.project_type != "squad" ? "disabled" : "enabled"
    "artifacts"    = var.project_type != "team" ? "disabled" : "enabled"
  }
}
resource "azuredevops_group_entitlement" "entitilement" {
  origin    = "aad"
  origin_id = var.entraid_group_id
  account_license_type = var.project_type != "squad" ? "express" : "stakeholder"
}
data "azuredevops_group" "group" {
  project_id = var.project_id
  name = "${var.project_name} Team"
}
resource "azuredevops_group_membership" "group_membership" {
  group = data.azuredevops_group.group.descriptor
  members = [
    azuredevops_group_entitlement.entitilement.descriptor
  ]
}
resource "azuredevops_iteration_permissions" "iteration_permissions" {
  project_id = var.project_id
  principal  = data.azuredevops_group.group.id
  permissions = {
    CREATE_CHILDREN = "Allow"
    GENERIC_WRITE   = "Allow"
    GENERIC_READ    = "Allow"
    DELETE          = "Deny"
  }
}
resource "azuredevops_area_permissions" "area_permissions" {
  project_id = var.project_id
  principal  = data.azuredevops_group.group.id
  permissions = {
    CREATE_CHILDREN = "Allow"
    GENERIC_READ    = "Allow"
    DELETE          = "Deny"
    WORK_ITEM_READ  = "Allow"
    WORK_ITEM_WRITE = "Allow"
  }
}

Debug Output

"https://gist.github.com/callumhester/59b1184efe617adc3c35aac79b06e5b0.js"

Expected Behavior

Azure DevOps project and associated resources should build. This was working fine on the 19th of March 2024, but come 20th, the error message starting appearing. No changes between the 19th and 20th, the code is the same.

Actual Behavior

When running Terraform plan or apply, the run crashes with error: Error: The terraform-provider-azuredevops_v1.0.1 plugin crashed!

Steps to Reproduce

  1. terraform apply
xuzhang3 commented 3 months ago

After the entitlement group deleted. The HTTP status code will be 200 but response will be null

https://learn.microsoft.com/en-us/rest/api/azure/devops/memberentitlementmanagement/group-entitlements/get?view=azure-devops-rest-7.1&tabs=HTTP

If the group entitlement does not exist, returns null.
callumhester commented 3 months ago

Hi,

Even after removing the entitlement and project manually. The issue still persists. I've dropped the provider version to 1.0.0 and the same issue appears. Very frustrating, as it's blocking my pipeline from completing and the Azure DevOps Terraform part is only 1 module out of many. Due to this, the remaining modules (azurerm) cannot be updated. If I remove the provider and module from the root of my terraform file, it is still in state, so it still errors.

callumhester commented 3 months ago

I've commented out the Azure DevOps module and left the provider + required provider inside the root main.tf. File it now no longer shows errors on the project or entitlement, but still crashes.

β”‚ Error: Plugin did not respond
β”‚ 
β”‚ The plugin encountered an error, and failed to respond to the
β”‚ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
β”‚ details.
β•΅

##[error]β•·
β”‚ Error: Plugin did not respond
β”‚ 
β”‚ The plugin encountered an error, and failed to respond to the
β”‚ plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more
β”‚ details.
β•΅

##[error]
Stack trace from the terraform-provider-azuredevops_v1.0.1 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xc4adc9]

Error: The terraform-provider-azuredevops_v1.0.1 plugin crashed!
xuzhang3 commented 3 months ago

@callumhester can you try remove the azuredevops_group_membership from the state file with terraform state rm xxx then remove the ADO configurations?