Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when importing an alert policy #360

Open
gdlx opened this issue Feb 8, 2023 · 2 comments · May be fixed by #420
Open

Panic when importing an alert policy #360

gdlx opened this issue Feb 8, 2023 · 2 comments · May be fixed by #420

Comments

@gdlx
Copy link

gdlx commented Feb 8, 2023

Hi,
I get a panic when importing an alert policy: https://gist.github.com/gdlx/19d7fcca60439d6c6b372e0db3a7addd

The import command is the following: terraform import opsgenie_alert_policy.add_tag 8a2e4b35-94ec-4192-a64f-f0ad52b8ef43

I have no issue to create/update/delete a policy, only when importing.

The alert policy template is the following:

resource "opsgenie_alert_policy" "add_tag" {
  name               = "Add Tag test"
  team_id            = data.opsgenie_team.my_team.id
  policy_description = "Adds TEST tag to all alerts."
  message            = "{{message}}"
  continue_policy    = true
  enabled            = false

  filter {}
  tags = ["TEST"]
}

Terraform version: 1.3.7
Opsgenie provider version: 0.6.20

@matthias-froomle
Copy link

When importing via team_id/policy_id the same issue happens:

│ 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.
╵


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

panic: interface conversion: error is *errors.errorString, not *client.ApiError

goroutine 29 [running]:
github.com/opsgenie/terraform-provider-opsgenie/opsgenie.resourceOpsGenieAlertPolicyRead({0x10122aa50?, 0x140004f2540?}, 0x14000606200, {0x1010f57c0?, 0x140001a9bf8?})
	github.com/opsgenie/terraform-provider-opsgenie/opsgenie/resource_opsgenie_alert_policy.go:357 +0xbd8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x14000432700, {0x10122aa50, 0x140004f2540}, 0x24?, {0x1010f57c0, 0x140001a9bf8})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:358 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x14000432700, {0x10122aa50, 0x140004f2540}, 0x1400020be10, {0x1010f57c0, 0x140001a9bf8})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:635 +0x30c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x14000304768, {0x10122aa50, 0x140004f2540}, 0x140004f25c0)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:576 +0x3d8
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadResource(0x14000345080, {0x10122aaf8?, 0x14000602210?}, 0x14000300f00)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:553 +0x310
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler({0x1011f5c20?, 0x14000345080}, {0x10122aaf8, 0x14000602210}, 0x14000300ea0, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000330700, {0x10122e900, 0x14000208480}, 0x140004c8100, 0x14000470300, 0x1016b1c90, 0x0)
	google.golang.org/[email protected]/server.go:1194 +0xaf0
google.golang.org/grpc.(*Server).handleStream(0x14000330700, {0x10122e900, 0x14000208480}, 0x140004c8100, 0x0)
	google.golang.org/[email protected]/server.go:1517 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:859 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:857 +0x298

Error: The terraform-provider-opsgenie_v0.6.28 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.

I am on provider version v0.6.28 with Terraform 1.0.4

@matthias-froomle
Copy link

Turned out I was importing a notification policy inside of a alert policy resource, so my issue is fixed, but maybe the provider shouldn't crash in this case

@jcardinal jcardinal linked a pull request Dec 21, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants