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

Provider panic when importing a cloudflare_workers_script #3949

Open
3 tasks done
Dieff opened this issue Sep 10, 2024 · 1 comment
Open
3 tasks done

Provider panic when importing a cloudflare_workers_script #3949

Dieff opened this issue Sep 10, 2024 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.

Comments

@Dieff
Copy link

Dieff commented Sep 10, 2024

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.9.5
on windows_amd64

  • provider registry.terraform.io/cloudflare/cloudflare v4.41.0

Affected resource(s)

  • cloudflare_workers_script

Terraform configuration files

I copied these from a larger repository. However they will work on their own.

terraform {
    required_providers {
        cloudflare = {
            source = "cloudflare/cloudflare"
            version = "4.41.0"
        }
    }
}

// requires the CLOUDFLARE_EMAIL and CLOUDFLARE_API_KEY environment variables
provider "cloudflare" {
}

variable "cf_account_id" {
  type = string
}

locals {
  # This is a sensitive to hide output in plan/apply.
  worker_script_content = sensitive(file(join("/", ["C:/Users/dieffenbache2/Workspace/irs-middleware-iac/CloudflareWorkers", "DRSFailover/dist/worker.mjs"])))
}

# this is an already existing workers script in our account.
# This general setup has worked for other workers
import {
  to = cloudflare_workers_script.drs_failover
  id = "${var.cf_account_id}/dev-drs-failover"
}

resource "cloudflare_workers_script" "drs_failover" {
  name       = "dev-drs-failover"
  account_id = "${var.cf_account_id}"
  content = sensitive(file(join("/", [local.worker_script_content, "DRSFailover/dist/worker.mjs"])))

  # We'll want to add the durable object binding here once it becomes available
  # Request: https://github.com/cloudflare/terraform-provider-cloudflare/issues/1320
}

Link to debug output

https://gist.github.com/Dieff/a5dfd6e2f502a133aec0220fcb5c60c0

Panic output

│ Error: Plugin did not respond

│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ImportResourceState call. The plugin logs may contain more details.

Stack trace from the terraform-provider-cloudflare_v4.41.0.exe plugin:

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

goroutine 39 [running]:
github.com/cloudflare/cloudflare-go.(*API).ListWorkerBindings(0xc000b14b00, {0x215aa58?, 0xc000dd6570}, 0xc000d2c8d8, {{0xc000d14061, 0x10}, 0xc000de02e0})
        github.com/cloudflare/[email protected]/workers_bindings.go:538 +0x107b
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.getWorkerScriptBindings({0x215aa58?, 0xc000dd6570?}, {0xc000d14040?, 0x0?}, {0xc000d14061?, 0x0?}, 0x0?, 0x1?)
        github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_workers_script.go:75 +0xd4
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareWorkerScriptRead({0x215aa58, 0xc000dd6570}, 0xc00015ec80, {0x1ea9320?, 0xc000b14b00})
        github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_workers_script.go:274 +0x5f1
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareWorkerScriptImport({0x215aa58, 0xc000dd6570}, 0xc00015ec80, {0x1ea9320, 0xc000b14b00})
        github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_workers_script.go:485 +0x289
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ImportState(0xc000a54700, {0x215aa58, 0xc000dd6570}, 0xc000c8d458, {0xc000d14040, 0x31})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/provider.go:475 +0x20c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ImportResourceState(0xc000008588, {0x215aa58?, 0xc000dd6450?}, 0xc000dd64e0)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1265 +0x60f
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ImportResourceState({{0x216a458?, 0xc000008588?}}, {0x215aa58?, 0xc000dd6450?}, 0xc00097cc00?)
        github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:104 +0x11a
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ImportResourceState(0x215aa90?, {0x215aa58?, 0xc00097cc90?}, 0xc00097cc00)
        github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ImportResourceState.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ImportResourceState(0xc000a6c5a0, {0x215aa58?, 0xc00097c240?}, 0xc0000a07d0)
        github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:896 +0x268
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ImportResourceState_Handler({0x1dce5e0?, 0xc000a6c5a0}, {0x215aa58, 0xc00097c240}, 0xc00015e880, 0x0)
        github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:536 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000b34200, {0x215aa58, 0xc00097c1b0}, {0x21631f8, 0xc000a6e300}, 0xc000d86000, 0xc000848450, 0x2fbbcf0, 0x0)
        google.golang.org/[email protected]/server.go:1369 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc000b34200, {0x21631f8, 0xc000a6e300}, 0xc000d86000)
        google.golang.org/[email protected]/server.go:1780 +0x1016
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/[email protected]/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 57
        google.golang.org/[email protected]/server.go:1030 +0x135

Error: The terraform-provider-cloudflare_v4.41.0.exe 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 maintaine

Expected output

I expected the cloudflare worker to be imported successfully. I imported several other workers in a similar way with no issues.

Actual output

The provider crashes during import.

Steps to reproduce

The provided main.tf file triggers the panic with a specific cloudflare worker. I haven't encountered the panic with other workers.

The dev_drs_failover cloudflare worker script is a simple worker written in Typescript and using the modules syntax. It has a single durable object binding. I am wondering if the durable object binding is causing the issue.

Additional factoids

No response

References

No response

@Dieff Dieff added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 10, 2024
Copy link
Contributor

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.
Projects
None yet
Development

No branches or pull requests

1 participant