cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
752 stars 575 forks source link

cloudflare_worker_script - ListWorkerBindings -> Interface conversion error #3466

Closed gbmarc1 closed 8 hours ago

gbmarc1 commented 1 month ago

Confirmation

Terraform and Cloudflare provider version

cloudflare/cloudflare v4.37.0 terraform_version: v1.6.6

Affected resource(s)

cloudflare_worker_script

Terraform configuration files

resource "cloudflare_worker_script" "worker" {
  account_id = data.cloudflare_accounts.staging.accounts[0].id
  name       = "portkey"
  content    = "addEventListener('fetch', async (event) => { return new Response('Hello, world!') })"

  lifecycle {
    ignore_changes = all
  }
}

Link to debug output

Can't provide this

Panic output

cloudflare_worker_script.worker: Refreshing state... [id=asdf]

Planning failed. Terraform encountered an error while generating this plan.

╷
│ 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-cloudflare_v4.37.0 plugin:

panic: interface conversion: interface {} is nil, not string

goroutine 30 [running]:
github.com/cloudflare/cloudflare-go.(*API).ListWorkerBindings(0xc00075c9a0, {0x20d9660?, 0xc000f477a0}, 0xc000f68838, {{0xc000b9ce30, 0x7}, 0xc001159b00})
    github.com/cloudflare/cloudflare-go@v0.99.0/workers_bindings.go:510 +0xfbb
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.getWorkerScriptBindings({0x20d9660?, 0xc000f477a0?}, {0xc000600940?, 0x0?}, {0xc000b9ce30?, 0x0?}, 0x0?, 0x1?)
    github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_workers_script.go:58 +0xd4
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareWorkerScriptRead({0x20d9660, 0xc000f477a0}, 0xc000b9f000, {0x1e378c0?, 0xc00075c9a0})
    github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_workers_script.go:257 +0x5f1
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000a49ce0, {0x20d95b8, 0xc00114c8d0}, 0xd?, {0x1e378c0, 0xc00075c9a0})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:823 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000a49ce0, {0x20d95b8, 0xc00114c8d0}, 0xc00066fc70, {0x1e378c0, 0xc00075c9a0})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:1117 +0x552
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000011668, {0x20d95b8?, 0xc00114c780?}, 0xc000c03140)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:708 +0x6ca
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x20e8178?, 0xc000011668?}}, {0x20d95b8?, 0xc00114c780?}, 0xc000c02f80?)
    github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:153 +0x2ab
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x20d95f0?, {0x20d95b8?, 0xc00114c480?}, 0xc000c02f80)
    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(0xc000b0a0a0, {0x20d95b8?, 0xc00113bc50?}, 0xc000f47180)
    github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:784 +0x309
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x1d5f300?, 0xc000b0a0a0}, {0x20d95b8, 0xc00113bc50}, 0xc000b9ed80, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:482 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000ef800, {0x20d95b8, 0xc00113bbc0}, {0x20e1a40, 0xc000bf2000}, 0xc00114b0e0, 0xc000b0cff0, 0x2f398c8, 0x0)
    google.golang.org/grpc@v1.63.2/server.go:1369 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc0000ef800, {0x20e1a40, 0xc000bf2000}, 0xc00114b0e0)
    google.golang.org/grpc@v1.63.2/server.go:1780 +0x1016
google.golang.org/grpc.(*Server).serveStreams.func2.1()
    google.golang.org/grpc@v1.63.2/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 70
    google.golang.org/grpc@v1.63.2/server.go:1030 +0x135

Error: The terraform-provider-cloudflare_v4.37.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.

Expected output

Plan succeeds

Actual output

Plan fails

Steps to reproduce

  1. Create a cloudflare_worker_script
  2. Modify the resource in cloudflare UI
  3. Plan again

Additional factoids

No response

References

No response

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

github-actions[bot] commented 1 month ago

Thank you for reporting this issue! For maintainers to dig into issues it is required that all issues include the entirety of TF_LOG=DEBUG output to be provided. The only parts that should be redacted are your user credentials in the X-Auth-Key, X-Auth-Email and Authorization HTTP headers. Details such as zone or account identifiers are not considered sensitive but can be redacted if you are very cautious. This log file provides additional context from Terraform, the provider and the Cloudflare API that helps in debugging issues. Without it, maintainers are very limited in what they can do and may hamper diagnosis efforts.

This issue has been marked with triage/needs-information and is unlikely to receive maintainer attention until the log file is provided making this a complete bug report.

github-actions[bot] commented 1 week ago

Marking this issue as stale due to 30 days of inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 7 days it will automatically be closed. Maintainers can also remove the lifecycle/stale label. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 8 hours ago

This issue was closed because it has been stalled for 7 days with no activity.