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 attempting to import cloudflare_dns_record #4916

Closed
3 tasks done
toadjaune opened this issue Jan 20, 2025 · 4 comments
Closed
3 tasks done

Provider panic when attempting to import cloudflare_dns_record #4916

toadjaune opened this issue Jan 20, 2025 · 4 comments
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

@toadjaune
Copy link

toadjaune commented Jan 20, 2025

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.10.4
on linux_amd64
+ provider registry.terraform.io/cloudflare/cloudflare v5.0.0-rc1

Affected resource(s)

  • cloudflare_dns_record

The above resource is the one I'm reproducing the issue consistently with. However, it may be much more widespread than that (I encountered a similar crash when attempting to refresh a cloudflare_api_token_permission_groups datasource)

Terraform configuration files

terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "5.0.0-rc1"
    }
  }
  backend "local" {
    path = "terraform.tfstate"
  }
}

# API token provided via CLOUDFLARE_API_TOKEN envvar
provider "cloudflare" {}

resource "cloudflare_dns_record" "test" {
  zone_id = <your_zone_id>
  name    = "test.<your_zone>"
  content = "example.com"
  type    = "CNAME"
  proxied = true
  ttl     = 1
}

Link to debug output

https://gist.github.com/toadjaune/0b5482c1ed049e8bdae28ee4cce3fb6d

Panic output

cloudflare_dns_record.test: Importing from ID "da3cf02194df30d9c38fd28a05f1f359/b32f907c61883e3c28dd3b5fe1eac50d"...
╷
│ 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_v5.0.0-rc1 plugin:

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

goroutine 19 [running]:
github.com/cloudflare/terraform-provider-cloudflare/internal/services/dns_record.(*DNSRecordResource).ImportState(0xc00102e3f8, {0x4388e08, 0xc00101c8a0}, {{0xc00101a000?, 0x3e5a3d1?}, {0x2d?}}, 0xc000d802a0)
        github.com/cloudflare/terraform-provider-cloudflare/internal/services/dns_record/resource.go:236 +0x1f0
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ImportResourceState(0xc00019bb08, {0x4388e08, 0xc00101c8a0}, 0xc000da4150, 0xc000d7f5f8)
        github.com/hashicorp/[email protected]/internal/fwserver/server_importresourcestate.go:136 +0x7ec
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ImportResourceState(0xc00019bb08, {0x4388e08?, 0xc00101c7b0?}, 0xc00101c750)
        github.com/hashicorp/[email protected]/internal/proto6server/server_importresourcestate.go:47 +0x2a5
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ImportResourceState(0xc000894960, {0x4388e08?, 0xc000d824e0?}, 0xc000d98140)
        github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:896 +0x24d
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ImportResourceState_Handler({0x3d977c0, 0xc000894960}, {0x4388e08, 0xc000d824e0}, 0xc000dae000, 0x0)
        github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:629 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001c0e00, {0x4388e08, 0xc000d82450}, {0x4419e60, 0xc000e72000}, 0xc000da8000, 0xc000d46180, 0x76887d0, 0x0)
        google.golang.org/[email protected]/server.go:1394 +0xe2b
google.golang.org/grpc.(*Server).handleStream(0xc0001c0e00, {0x4419e60, 0xc000e72000}, 0xc000da8000)
        google.golang.org/[email protected]/server.go:1805 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/[email protected]/server.go:1029 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 55
        google.golang.org/[email protected]/server.go:1040 +0x125

Error: The terraform-provider-cloudflare_v5.0.0-rc1 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

A successful resource import

Actual output

Same as panic output above

Steps to reproduce

  • Put the example configuration in a file, and adapt it to point to your zone
  • terraform apply to create the entry
  • terraform state show cloudflare_dns_record.test to display the entry details
  • write down the record id for importing it later
  • terraform state rm cloudflare_dns_record.test to remove the entry from the state but not from cloudflare
  • terraform import cloudflare_dns_record.test <zone_id>/<record_id>

Additional factoids

Provider version 4.50 is unaffected by this issue (well, the cloudflare_record resource there, since it changed name in the meantime), this seems to be a regression introduced by the major provider rewrite.

I'm unsure how close to stable rc1 is meant to be, but I'm assuming this issue ought to be a blocker for stable release.

References

No response

@toadjaune toadjaune 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 Jan 20, 2025
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 Jan 20, 2025
@drewmullen
Copy link

I ran into the same thing (duplicated)

@jacobbednarz
Copy link
Member

duplicate of #4883 which is already fixed in the development branch pending a release.

@toadjaune
Copy link
Author

Oh, thanks, and sorry for the duplicate !

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

3 participants