terraform-provider-pagerduty icon indicating copy to clipboard operation
terraform-provider-pagerduty copied to clipboard

Runtime error with resource_pagerduty_incident_workflow

Open sgujavarthy opened this issue 10 months ago • 3 comments

We are getting the following error while refreshing during terrafrom plan after adding couple of workflows - pagerduty_incident_workflow

Terraform Configuration Files

esource "pagerduty_incident_workflow" "workflow-assign-change-review-one-test" {
  name        = "Test-INC - Status Update test"
  description = "Managed by Terraform in github"
  team        = "xxxxxx"
  step {
    name   = "Create a Task"
    action = "pagerduty.com:tasks:create-task:1"
    input {
      name  = "Task name"
      value = "Change Review"
    }
    input {
      name  = "Details"
      value = "Review changes at URL xxxxx"
    }
  }
}

Panic Output

Stack trace from the terraform-provider-pagerduty_v3.11.0 plugin:

panic: runtime error: index out of range [4] with length 4

goroutine 119274 [running]:
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.flattenIncidentWorkflowSteps(0x140004da3f0, {0x140014c09e0, 0x4, 0x10140bce0?}, 0x0)
	github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:500 +0x6c4
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.flattenIncidentWorkflow(0x14000730248?, 0x140004da3f0, 0x1, {0x140014c09e0, 0x4, 0x4}, 0x88?)
	github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:482 +0x108
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.fetchIncidentWorkflow.func1()
	github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:458 +0x294
github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.RetryContext.func1()
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/wait.go:30 +0x48
github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.(*StateChangeConf).WaitForStateContext.func1()
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/state.go:113 +0x144
created by github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.(*StateChangeConf).WaitForStateContext
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/state.go:86 +0x1a4

Error: The terraform-provider-pagerduty_v3.11.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.

sgujavarthy avatar Apr 04 '24 03:04 sgujavarthy

I am also impacted by this issue. I encounter this on version 3.8.1 of the plugin on terraform 1.5.3, as well as with 3.11.4 on terraform 1.7.3.

TF 1.5.3 / plugin 3.8.1

Stack trace from the terraform-provider-pagerduty_v3.8.1 plugin:

panic: runtime error: index out of range [1] with length 1

goroutine 168 [running]:
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.flattenIncidentWorkflowSteps(0x14000710af0, {0x14000526628, 0x1, 0x1039c82e0?}, 0x0)
        github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:500 +0x6c4
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.flattenIncidentWorkflow(0x1400000ea28?, 0x14000710af0, 0x1, {0x14000526628, 0x1, 0x1}, 0x88?)
        github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:482 +0x108
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.fetchIncidentWorkflow.func1()
        github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:458 +0x294
github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.RetryContext.func1()
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/wait.go:30 +0x48
github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.(*StateChangeConf).WaitForStateContext.func1()
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/state.go:113 +0x144
created by github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.(*StateChangeConf).WaitForStateContext
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/state.go:86 +0x1a4

Error: The terraform-provider-pagerduty_v3.8.1 plugin crashed!

TF 1.7.3 / plugin 3.11.4

Stack trace from the terraform-provider-pagerduty_v3.11.4 plugin:

panic: runtime error: index out of range [1] with length 1

goroutine 110 [running]:
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.flattenIncidentWorkflowSteps(0x140004ec000, {0x140002886b0, 0x1, 0x1057c3ce0?}, 0x0)
        github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:500 +0x6c4
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.flattenIncidentWorkflow(0x140004c01b0?, 0x140004ec000, 0x1, {0x140002886b0, 0x1, 0x1}, 0x88?)
        github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:482 +0x108
github.com/PagerDuty/terraform-provider-pagerduty/pagerduty.fetchIncidentWorkflow.func1()
        github.com/PagerDuty/terraform-provider-pagerduty/pagerduty/resource_pagerduty_incident_workflow.go:458 +0x294
github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.RetryContext.func1()
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/wait.go:30 +0x48
github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.(*StateChangeConf).WaitForStateContext.func1()
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/state.go:113 +0x144
created by github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry.(*StateChangeConf).WaitForStateContext
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/retry/state.go:86 +0x1a4

Error: The terraform-provider-pagerduty_v3.11.4 plugin crashed!

mharriscircleci avatar Apr 26 '24 21:04 mharriscircleci

After some testing, this bug is introduced in v3.2.0 of the plugin.

mharriscircleci avatar Apr 29 '24 15:04 mharriscircleci

I was also experiencing this plugin crash with the following:

Terraform v1.8.2 PagerDuty provider v3.11.4

I reverted to PagerDuty provider v3.9.0 but was still experiening the crash. From reading about this crash on other forums I tried deleting the .terraform folder and running terraform init but still experienced the crashing with terraform plan or terraform apply.

We're not using workflows extensively so this might not be a workaround for everyone, but I ended up removing all pagerduty_incident_workflow and pagerduty_incident_workflow_trigger resources from state via terraform state rm and then importing them back in via terraform import. After doing this, I ran terraform plan and the crash is no longer occurring.

kyub avatar May 01 '24 10:05 kyub