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

Worker script's script_name field can be null #1517

Open
2 tasks done
skyf0l opened this issue Mar 8, 2024 · 1 comment
Open
2 tasks done

Worker script's script_name field can be null #1517

skyf0l opened this issue Mar 8, 2024 · 1 comment

Comments

@skyf0l
Copy link

skyf0l commented Mar 8, 2024

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the library and it is still present.

cloudflare-go version

v0.89.0

Expected output

See on documentation (https://developers.cloudflare.com/api/operations/worker-script-get-settings), durable object have an optional script_name field :
image

The actual API usually return it but after after the binding using wrangler, the API doesn't return it.

$ curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/workers/scripts/{script_name}/settings" -H "Authorization: Bearer XXX"                                                                    
{
  "result": {
    "placement": {},
    "compatibility_date": "2023-09-22",
    "compatibility_flags": [],
    "usage_model": "standard",
    "tags": [],
    "tail_consumers": [],
    "logpush": false,
    "bindings": [
      {
        "class_name": "Project",
        "environment": "production",
        "name": "DURABLE_OBJECT",
        "namespace_id": "XXX",
        "type": "durable_object_namespace"
      }
    ]
  },
  "success": true,
  "errors": [],
  "messages": []
}

This make the terraform-provider-cloudflare_v4.26.0 plugin crash, and make me unable to use terraform on my cloudflare env after adding a durable object binding using wrangler.

I'm not into go development but I've located the bug (https://github.com/cloudflare/cloudflare-go/blob/v0.89.0/workers_bindings.go#L506) and I think I just need to allow this value as optional.

I hope this can be resolved,

@skyf0l
Copy link
Author

skyf0l commented Mar 9, 2024

Here my terraform error log if it can help

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

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

goroutine 68 [running]:
github.com/cloudflare/cloudflare-go.(*API).ListWorkerBindings(0xc0006ec8f0, {0x13e4130?, 0xc0003f33b0}, 0xc0007529a0, {{0xc0007186c0, 0x1a}})
        github.com/cloudflare/[email protected]/workers_bindings.go:506 +0xedb
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.getWorkerScriptBindings({0x13e4130?, 0xc0003f33b0?}, {0xc000718680?, 0x0?}, {0xc0007186c0?, 0x0?}, 0x0?)
        github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_workers_script.go:58 +0xd3
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareWorkerScriptRead({0x13e4130, 0xc0003f33b0}, 0xc000720700, {0x11d4ea0?, 0xc0006ec8f0})
        github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_workers_script.go:237 +0x569
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0000da540, {0x13e4088, 0xc0007a57a0}, 0xd?, {0x11d4ea0, 0xc0006ec8f0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:795 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000da540, {0x13e4088, 0xc0007a57a0}, 0xc00031a1a0, {0x11d4ea0, 0xc0006ec8f0})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1089 +0x552
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000010228, {0x13e4088?, 0xc0007a5650?}, 0xc0003cdc80)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:666 +0x48a
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x13eaf60?, 0xc000010228?}}, {0x13e4088?, 0xc0007a5650?}, 0xc0003cda80?)
        github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:218 +0x225
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x13e40c0?, {0x13e4088?, 0xc0007a52c0?}, 0xc0003cda80)
        github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadResource.go:35 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc0003eb7c0, {0x13e4088?, 0xc0007a49f0?}, 0xc000704840)
        github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:775 +0x4c3
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x11a6fe0?, 0xc0003eb7c0}, {0x13e4088, 0xc0007a49f0}, 0xc000720480, 0x0)
        github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:482 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000179000, {0x13e4088, 0xc0007a4960}, {0x13e9810, 0xc000500b60}, 0xc00074c6c0, 0xc000578d80, 0x1afb048, 0x0)
        google.golang.org/[email protected]/server.go:1383 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc000179000, {0x13e9810, 0xc000500b60}, 0xc00074c6c0)
        google.golang.org/[email protected]/server.go:1794 +0x100c
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/[email protected]/server.go:1027 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 55
        google.golang.org/[email protected]/server.go:1038 +0x135

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

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

No branches or pull requests

1 participant