opsgenie / terraform-provider-opsgenie

Terraform OpsGenie provider
https://registry.terraform.io/providers/opsgenie/opsgenie/latest/docs
Mozilla Public License 2.0
100 stars 136 forks source link

segfault when using opsgenie_escalation datasource #359

Open broestls opened 1 year ago

broestls commented 1 year ago

Hi, I'm running into a segfault/crash/plugin did not respond error when executing a trivial code sample involving the opsgenie_escalation data source.

terraform version: 1.3.7 platform: darwin_arm64 (not sure if it matters, but I thought I'd mention) affected resources: data.opsgenie_escalation (haven't tested on resource yet)

Sample config

terraform {
  required_providers {
    opsgenie = {
      source  = "opsgenie/opsgenie"
      version = "0.6.20"
    }
  }
}

provider "opsgenie" {
  api_url = var.opsgenie_api_url
}

data "opsgenie_escalation" "test" {
  name = "Team2_escalation"
}

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

Debug Output

debug gist: https://gist.github.com/broestls/d5718348869d433be89d6d8c94e29cfe

Panic Output

Honestly, may be the above gist as well.

Expected Behavior

Should have given me information about the named escalation object

Actual Behavior

plugin did not respond

Steps to Reproduce

  1. terraform plan

Important Factoids

Running against JSM-integrated version of opsgenie

References

None at this time

mhubig commented 1 year ago

Same problem here, I get this stacktrace msg:

Stack trace from the terraform-provider-opsgenie_v0.6.20 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x4 pc=0x1009b6a10]

goroutine 52 [running]:
github.com/opsgenie/terraform-provider-opsgenie/opsgenie.flattenOpsgenieEscalationRepeat(...)
        github.com/opsgenie/terraform-provider-opsgenie/opsgenie/resource_opsgenie_escalation.go:242
github.com/opsgenie/terraform-provider-opsgenie/opsgenie.dataSourceOpsgenieEscalationRead(0x1060?, {0x100b617e0?, 0x14000112178?})
        github.com/opsgenie/terraform-provider-opsgenie/opsgenie/data_source_opsgenie_escalation.go:121 +0x220
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x1009fa014?, {0x100c96a50?, 0x14000564000?}, 0x14000346060?, {0x100b617e0?, 0x14000112178?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:346 +0x138
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0x14000417340, {0x100c96a50, 0x14000564000}, 0x14000339c80, {0x100b617e0, 0x14000112178})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:569 +0xe4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0x1400000c768, {0x100c96a50, 0x14000564000}, 0x1400032a620)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/grpc_provider.go:1133 +0x2c0
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0x140000a5100, {0x100c96af8?, 0x1400031d350?}, 0x14000320640)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:478 +0x2e0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x100c61c40?, 0x140000a5100}, {0x100c96af8, 0x1400031d350}, 0x140005966c0, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:416 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x140000c2700, {0x100c9a900, 0x14000208480}, 0x14000328100, 0x1400044a300, 0x10111dcf0, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1194 +0xaf0
google.golang.org/grpc.(*Server).handleStream(0x140000c2700, {0x100c9a900, 0x14000208480}, 0x14000328100, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1517 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.32.0/server.go:859 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.32.0/server.go:857 +0x298

Error: The terraform-provider-opsgenie_v0.6.20 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.
tblakers commented 1 year ago

Same problem in 0.6.29:

Error: Plugin did not respond
│ 
│   with data.opsgenie_escalation.test,
│   on data_teams.tf line 14, in data "opsgenie_escalation" "test":
│   14: data "opsgenie_escalation" "test" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadDataSource call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-opsgenie_v0.6.29 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x4 pc=0x10309abf0]

goroutine 69 [running]:
github.com/opsgenie/terraform-provider-opsgenie/opsgenie.flattenOpsgenieEscalationRepeat(...)
        github.com/opsgenie/terraform-provider-opsgenie/opsgenie/resource_opsgenie_escalation.go:242
github.com/opsgenie/terraform-provider-opsgenie/opsgenie.dataSourceOpsgenieEscalationRead(0x5040?, {0x1032457c0?, 0x1400000e268?})
        github.com/opsgenie/terraform-provider-opsgenie/opsgenie/data_source_opsgenie_escalation.go:121 +0x220
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x1030de554?, {0x10337aa50?, 0x140002d3a00?}, 0x140005228a0?, {0x1032457c0?, 0x1400000e268?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:346 +0x138
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0x140003b5340, {0x10337aa50, 0x140002d3a00}, 0x14000524180, {0x1032457c0, 0x1400000e268})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/resource.go:569 +0xe4
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0x14000292750, {0x10337aa50, 0x140002d3a00}, 0x14000336fa0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.10.0/helper/schema/grpc_provider.go:1133 +0x2c0
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0x140002c5100, {0x10337aaf8?, 0x14000513d40?}, 0x1400030f1d0)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/tf5server/server.go:478 +0x2e0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x103345c20?, 0x140002c5100}, {0x10337aaf8, 0x14000513d40}, 0x14000475740, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.5.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:416 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x140002b0700, {0x10337e900, 0x1400047e000}, 0x14000514a00, 0x140003f2240, 0x103801cf0, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1194 +0xaf0
google.golang.org/grpc.(*Server).handleStream(0x140002b0700, {0x10337e900, 0x1400047e000}, 0x14000514a00, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1517 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.32.0/server.go:859 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.32.0/server.go:857 +0x298

Error: The terraform-provider-opsgenie_v0.6.29 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.
michaelkanis-dmtech commented 10 months ago

Still persists in 0.6.34

tylerbrewer2 commented 9 months ago

I get the same error.

It's due to dataSourceOpsgenieEscalationRead not handling an escalation without a repeat setting here. Which is why the nil pointer reference is thrown in flattenOpsgenieEscalationRepeat