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

SIGSEGV in cloudflare_tunnel_config: nil pointer dereference #2487

Closed
2 tasks done
Bakus opened this issue May 31, 2023 · 10 comments · Fixed by #2504
Closed
2 tasks done

SIGSEGV in cloudflare_tunnel_config: nil pointer dereference #2487

Bakus opened this issue May 31, 2023 · 10 comments · Fixed by #2504
Labels
kind/bug Categorizes issue or PR as related to a bug. service/tunnel Categorizes issue or PR as related to the Tunnel service. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. workflow/synced
Milestone

Comments

@Bakus
Copy link

Bakus commented May 31, 2023

Confirmation

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

Terraform and Cloudflare provider version

Terraform v1.4.6
on linux_amd64

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

Affected resource(s)

  • cloudflare_tunnel_config

Terraform configuration files

resource "cloudflare_tunnel_config" "xx-xx-1" {
  account_id = var.account_id
  tunnel_id  = cloudflare_tunnel.managed_tunnel["xx-xx-1"].id

  config {
    warp_routing {
      enabled = true
    }
    origin_request {
      no_tls_verify = true
    }
    ingress_rule {
      hostname = "xxx.xxxxxxxxxx.xxx"
      service  = "https://10.0.0.1:8006"
    }
    ingress_rule {
      service = "http_status:501"
    }
  }
}

Link to debug output

https://gist.github.com/Bakus/9619aed6bfced259c7d4dc84f61f5ffa

Panic output

Stack trace from the terraform-provider-cloudflare_v4.7.1 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb3b149]

goroutine 523 [running]:
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.parseOriginRequest({0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0007d203a, ...})
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:122 +0x49
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareTunnelConfigRead({0x11bc860, 0xc0006bb4a0}, 0xc000138700, {0xffbde0?, 0xc00052a000})
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:233 +0xc58
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareTunnelConfigImport({0x11bc860, 0xc0006bb4a0}, 0xc000138700, {0xffbde0?, 0xc00052a000?})
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:297 +0x4f6
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Provider).ImportState(0xc0000910e0, {0x11bc860, 0xc0006bb4a0}, 0xc00010f390, {0xc0005f60a0, 0x41})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/provider.go:385 +0x1ac
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ImportResourceState(0xc0000112c0, {0x11bc860?, 0xc00049dd40?}, 0xc0005fc220)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1088 +0xf4
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ImportResourceState({{0x11c25f0?, 0xc0000112c0?}}, {0x11bc860?, 0xc00049dd40?}, 0xc0005fc200?)
github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:67 +0xd0
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.muxServer.ImportResourceState({0xc0003acba0, 0xc0003acc00, {0xc0004311a0, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ImportResourceState.go:27 +0x102
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ImportResourceState(0xc0004f9220, {0x11bc860?, 0xc00049ccc0?}, 0xc00087a730)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:846 +0x1f6
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ImportResourceState_Handler({0xfcc460?, 0xc0004f9220}, {0x11bc860, 0xc00049ccc0}, 0xc00019e070, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:437 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004f05a0, {0x11c1578, 0xc000500680}, 0xc0006bed80, 0xc0003e88a0, 0x17c1458, 0x0)
google.golang.org/[email protected]/server.go:1345 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc0004f05a0, {0x11c1578, 0xc000500680}, 0xc0006bed80, 0x0)
google.golang.org/[email protected]/server.go:1722 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/[email protected]/server.go:966 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:964 +0x28a

Error: The terraform-provider-cloudflare_v4.7.1 plugin crashed!

Expected output

Working import and update of cloudflare_tunnel_config

Actual output

panic from GO

Steps to reproduce

TF_LOG=TRACE TF_LOG_PATH=./tf-471-import.log terraform import cloudflare_tunnel_config.fi-vm-1 cd92ce0a01c0f5c705c792b83b120a8b/bfbd542b83a3428b84d69996d003c13a
or do anything with cloudflare_tunnel_config

Additional factoids

func parseOriginRequest(originRequest cloudflare.OriginRequestConfig) (returnValue []map[string]interface{}) {
- all elements expects some value, but values can be returned as null from API

2023-05-31T14:20:50.945+0200 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: GetTunnelConfiguration: {TunnelID:bfbd542b-83a3-428b-84d6-9996d003c13a Config:{Ingress:[{Hostname:adm-proxmox.tensquaregames.team Path: Service:https://10.18.4.1:8006 OriginRequest:0xc0004f8320} {Hostname: Path: Service:http_status:501 OriginRequest:<nil>}] WarpRouting:0xc0007d203b OriginRequest:{ConnectTimeout:<nil> TLSTimeout:<nil> TCPKeepAlive:<nil> NoHappyEyeballs:<nil> KeepAliveConnections:<nil> KeepAliveTimeout:<nil> HTTPHostHeader:<nil> OriginServerName:<nil> CAPool:<nil> NoTLSVerify:<nil> DisableChunkedEncoding:<nil> BastionMode:<nil> ProxyAddress:<nil> ProxyPort:<nil> ProxyType:<nil> IPRules:[] Http2Origin:<nil> Access:<nil>}} Version:26}: tf_rpc=ImportResourceState @module=cloudflare tf_mux_provider=tf5to6server.v5tov6Server tf_req_id=b2a37622-47b9-fce2-c7ec-3b54172d94f5 tf_resource_type=cloudflare_tunnel_config @caller=github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:192 tf_provider_addr=registry.terraform.io/cloudflare/cloudflare timestamp=2023-05-31T14:20:50.945+0200

References

No response

@Bakus Bakus 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 May 31, 2023
@github-actions
Copy link
Contributor

Terraform debug log detected ✅

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label May 31, 2023
@github-actions
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.

@jacobbednarz jacobbednarz added triage/accepted Indicates an issue or PR is ready to be actively worked on. service/tunnel Categorizes issue or PR as related to the Tunnel service. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/accepted Indicates an issue or PR is ready to be actively worked on. labels Jun 1, 2023
@ruimarinho
Copy link
Contributor

If it's helpful, here's a similar configuration:

2023-06-01T19:58:52.578+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: GET /client/v4/accounts/<account_id>/cfd_tunnel/<tunnel_id>/configurations HTTP/1.1
2023-06-01T19:58:52.578+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Host: api.cloudflare.com
2023-06-01T19:58:52.578+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: User-Agent: terraform/1.4.6 terraform-plugin-sdk/2.10.1 terraform-provider-cloudflare/4.7.1
2023-06-01T19:58:52.578+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Authorization: Bearer [redacted]
2023-06-01T19:58:52.578+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Content-Type: application/json
2023-06-01T19:58:52.578+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Accept-Encoding: gzip
2023-06-01T19:58:52.578+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1:
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 2023/06/01 19:58:53
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: HTTP/2.0 200 OK
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Cf-Cache-Status: DYNAMIC
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Cf-Ray: <cf-ray>
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Content-Type: application/json
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Date: Thu, 01 Jun 2023 18:58:53 GMT
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Server: cloudflare
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Set-Cookie: __cflb=0H28vgHxwvgAQtjUGU56Rb8iNWZVUvXhcsWVjFiCd41; SameSite=Lax; path=/; expires=Thu, 01-Jun-23 21:28:54 GMT; HttpOnly
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Set-Cookie: __cfruid=6376b75be67511b5287adda7b8f95ac4e049ebaf-1685645933; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: Vary: Accept-Encoding
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: X-Envoy-Upstream-Service-Time: 1
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1:
2023-06-01T19:58:53.501+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: {"success":true,"messages":[],"errors":[],"result":{"tunnel_id":"<tunnel_id>","version":13,"config":{"ingress":[{"service":"http://foo.local","hostname":"foo.example.com","originRequest":{"http2Origin":false,"httpHostHeader":"myservice.example.dev","originServerName":""}},{"service":"http_status:404"}],"warp-routing":{"enabled":false}},"source":"cloudflare","created_at":"2023-05-17T15:25:24.610695Z"}}
2023-06-01T19:58:53.504+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: GetTunnelConfiguration: {TunnelID:<tunnel_id> Config:{Ingress:[{Hostname:foo.example.com Path: Service:http://foo.local OriginRequest:0x1400062ba40} {Hostname: Path: Service:http_status:404 OriginRequest:<nil>}] WarpRouting:0x1400054c613 OriginRequest:{ConnectTimeout:<nil> TLSTimeout:<nil> TCPKeepAlive:<nil> NoHappyEyeballs:<nil> KeepAliveConnections:<nil> KeepAliveTimeout:<nil> HTTPHostHeader:<nil> OriginServerName:<nil> CAPool:<nil> NoTLSVerify:<nil> DisableChunkedEncoding:<nil> BastionMode:<nil> ProxyAddress:<nil> ProxyPort:<nil> ProxyType:<nil> IPRules:[] Http2Origin:<nil> Access:<nil>}} Version:13}: tf_req_id=c653f621-12c1-880e-ce88-6e34fb08b946 tf_resource_type=cloudflare_tunnel_config @module=cloudflare tf_mux_provider=tf5to6server.v5tov6Server tf_provider_addr=registry.terraform.io/cloudflare/cloudflare tf_rpc=ReadResource @caller=github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:192 timestamp=2023-06-01T19:58:53.504+0100
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: panic: runtime error: invalid memory address or nil pointer dereference
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: [signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10152e8a8]
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1:
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: goroutine 133 [running]:
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.parseOriginRequest({0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x14000692280, 0x14000692290, 0x0, 0x0, ...})
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:122 +0x38
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareTunnelConfigRead({0x101b96608, 0x1400040a5d0}, 0x140004a4a00, {0x101b859c0?, 0x140005f2cc0})
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:233 +0xa54
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x140003b20e0, {0x101b96640, 0x140003fcf00}, 0xd?, {0x101b859c0, 0x140005f2cc0})
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:724 +0xe8
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0x140003b20e0, {0x101b96640, 0x140003fcf00}, 0x14000697d40, {0x101b859c0, 0x140005f2cc0})
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x46c
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0x1400000d338, {0x101b96640?, 0x140003fcd80?}, 0x14000536100)
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x400
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x101b9c270?, 0x1400000d338?}}, {0x101b96640?, 0x140003fcd80?}, 0x140000fbf40?)
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:105 +0x264
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/hashicorp/terraform-plugin-mux/tf6muxserver.muxServer.ReadResource({0x140003aabd0, 0x140003aac30, {0x140005a8bc0, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadResource.go:26 +0xdc
2023-06-01T19:58:53.507+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0x1400062a820, {0x101b96640?, 0x1400062dc20?}, 0x14000141740)
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:746 +0x3e8
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x101b567a0?, 0x1400062a820}, {0x101b96640, 0x1400062dc20}, 0x140006b9500, 0x0)
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:383 +0x170
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: google.golang.org/grpc.(*Server).processUnaryRPC(0x140004b25a0, {0x101b9b2f8, 0x140005824e0}, 0x140001677a0, 0x140003c6900, 0x10217e390, 0x0)
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	google.golang.org/[email protected]/server.go:1345 +0xc90
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: google.golang.org/grpc.(*Server).handleStream(0x140004b25a0, {0x101b9b2f8, 0x140005824e0}, 0x140001677a0, 0x0)
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	google.golang.org/[email protected]/server.go:1722 +0x82c
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: google.golang.org/grpc.(*Server).serveStreams.func1.2()
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	google.golang.org/[email protected]/server.go:966 +0x84
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: created by google.golang.org/grpc.(*Server).serveStreams.func1
2023-06-01T19:58:53.508+0100 [DEBUG] provider.terraform-provider-cloudflare_v4.7.1: 	google.golang.org/[email protected]/server.go:964 +0x28c
2023-06-01T19:58:53.510+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/4.7.1/darwin_arm64/terraform-provider-cloudflare_v4.7.1 pid=46159 error="exit status 2"
2023-06-01T19:58:53.511+0100 [ERROR] plugin6.(*GRPCProvider).ReadResource: error="rpc error: code = Canceled desc = context canceled"
2023-06-01T19:58:53.511+0100 [ERROR] vertex "cloudflare_tunnel_config.vpc_production_cluster_production_data_config" error: Request cancelled
2023-06-01T19:58:53.511+0100 [ERROR] vertex "cloudflare_tunnel_config.vpc_production_cluster_production_data_config (expand)" error: Request cancelled
2023-06-01T19:58:53.511+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Canceled desc = context canceled"```

@stefandanaita
Copy link

Yep, happens to me as well when updating the tunnel config resource.

@szandala

This comment was marked as off-topic.

@lwimmer
Copy link

lwimmer commented Jun 14, 2023

I can still reproduce this issue with v4.8.0:

Stack trace from the terraform-provider-cloudflare_v4.8.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xb45249]

goroutine 1874 [running]:
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.parseOriginRequest({0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:122 +0x49
github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider.resourceCloudflareTunnelConfigRead({0x11cd028, 0xc000882660}, 0xc00063f100, {0x1009900?, 0xc00064e000})
	github.com/cloudflare/terraform-provider-cloudflare/internal/sdkv2provider/resource_cloudflare_tunnel_config.go:233 +0xc58
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0003b61c0, {0x11cd060, 0xc00043baa0}, 0xd?, {0x1009900, 0xc00064e000})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:724 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0003b61c0, {0x11cd060, 0xc00043baa0}, 0xc000b0c750, {0x1009900, 0xc00064e000})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1015 +0x585
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0000112f0, {0x11cd060?, 0xc00043b920?}, 0xc00045c640)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:613 +0x4a5
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x11d2df0?, 0xc0000112f0?}}, {0x11cd060?, 0xc00043b920?}, 0xc00045c4c0?)
	github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:105 +0x242
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.muxServer.ReadResource({0xc0003b0b10, 0xc0003b0b70, {0xc00044c7e0, 0x2, 0x2}, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...)
	github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadResource.go:26 +0x102
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc0004d4820, {0x11cd060?, 0xc00043a7e0?}, 0xc00051eb40)
	github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:746 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0xfd9d40?, 0xc0004d4820}, {0x11cd060, 0xc00043a7e0}, 0xc000256310, 0x0)
	github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:383 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0004ca5a0, {0x11d1d78, 0xc000502820}, 0xc000470240, 0xc0003e8c30, 0x17d6530, 0x0)
	google.golang.org/[email protected]/server.go:1345 +0xdf3
google.golang.org/grpc.(*Server).handleStream(0xc0004ca5a0, {0x11d1d78, 0xc000502820}, 0xc000470240, 0x0)
	google.golang.org/[email protected]/server.go:1722 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:966 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:964 +0x28a

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

@jippi
Copy link

jippi commented Jun 17, 2023

Seems to be introducedin 74b7b26

it references originRequest.ConnectTimeout.String(), but ConnectTimeout isnilable, so Go panics when trying to take the String() value of it

it was set in https://github.com/cloudflare/terraform-provider-cloudflare/blob/master/internal/sdkv2provider/resource_cloudflare_tunnel_config.go#L37-L40

It's pretty likely the other nil'able fields introduced 3 weeks ago got the same issue

It was introduced in v4.7.0

cc: @Cyb3r-Jak3

@Cyb3r-Jak3
Copy link
Contributor

It's pretty likely the other nil'able fields introduced 3 weeks ago got the same issue

Yeah, any field with that is a *time.Duration can trigger the nil pointer error. I'm not 100% sure what cause it to be nil given we set defaults but #2504 should handle all nil cases.

@jippi
Copy link

jippi commented Jun 17, 2023

Oh nice, you already made a fix 🎉 too bad its been hanging for a couple of weeks - anything I can help to support it getting merged in? :)

@github-actions github-actions bot added this to the v4.9.0 milestone Jun 22, 2023
@jacobbednarz jacobbednarz mentioned this issue Jun 25, 2023
2 tasks
@github-actions
Copy link
Contributor

This functionality has been released in v4.9.0 of the Terraform Cloudflare Provider.

Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. service/tunnel Categorizes issue or PR as related to the Tunnel service. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. workflow/synced
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants