Skip to content

Terraform crashes on mirroring the cloudflare provider #35318

@zoonage

Description

@zoonage

Terraform Version

% terraform version
Terraform v1.8.5
on darwin_arm64


### Terraform Configuration Files

```terraform
terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = ">= 4.0.0, < 5.0.0"
    }
  }
}

provider "cloudflare" {}

Debug Output

% tftest % TF_LOG=trace terraform providers mirror .
2024-06-10T11:05:27.576+0100 [INFO]  Terraform version: 1.8.5
2024-06-10T11:05:27.577+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.51.0
2024-06-10T11:05:27.577+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.20.0
2024-06-10T11:05:27.577+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-06-10T11:05:27.577+0100 [DEBUG] using github.com/zclconf/go-cty v1.14.3
2024-06-10T11:05:27.577+0100 [INFO]  Go runtime version: go1.22.1
2024-06-10T11:05:27.577+0100 [INFO]  CLI args: []string{"terraform", "providers", "mirror", "."}
2024-06-10T11:05:27.577+0100 [TRACE] Stdout is a terminal of width 98
2024-06-10T11:05:27.577+0100 [TRACE] Stderr is a terminal of width 98
2024-06-10T11:05:27.577+0100 [TRACE] Stdin is a terminal
2024-06-10T11:05:27.577+0100 [DEBUG] Attempting to open CLI config file: /Users/<REDACTED>>/.terraform.d/config.tf
2024-06-10T11:05:27.577+0100 [INFO]  Loading CLI configuration from /Users/<REDACTED>>/.terraform.d/config.tf
2024-06-10T11:05:27.577+0100 [DEBUG] Not reading CLI config directory because config location is overridden by environment variable
2024-06-10T11:05:27.577+0100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-06-10T11:05:27.577+0100 [DEBUG] ignoring non-existing provider search directory /Users/<REDACTED>>/.terraform.d/plugins
2024-06-10T11:05:27.577+0100 [DEBUG] ignoring non-existing provider search directory /Users/<REDACTED>>/Library/Application Support/io.terraform/plugins
2024-06-10T11:05:27.577+0100 [DEBUG] ignoring non-existing provider search directory /Library/Application Support/io.terraform/plugins
2024-06-10T11:05:27.577+0100 [INFO]  CLI command args: []string{"providers", "mirror", "."}
2024-06-10T11:05:27.577+0100 [TRACE] Config.VerifyDependencySelections: provider registry.terraform.io/cloudflare/cloudflare has no lock file entry to satisfy ">= 4.0.0, < 5.0.0"
- Mirroring cloudflare/cloudflare...
2024-06-10T11:05:27.578+0100 [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2024-06-10T11:05:27.578+0100 [TRACE] HTTP client GET request to https://registry.terraform.io/.well-known/terraform.json
2024-06-10T11:05:27.609+0100 [DEBUG] GET https://registry.terraform.io/v1/providers/cloudflare/cloudflare/versions
2024-06-10T11:05:27.609+0100 [TRACE] HTTP client GET request to https://registry.terraform.io/v1/providers/cloudflare/cloudflare/versions

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

panic: runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x64
github.com/hashicorp/terraform/internal/logging.PanicHandler()
	github.com/hashicorp/terraform/internal/logging/panic.go:84 +0x198
panic({0x1030e7e00?, 0x104ff1640?})
	runtime/panic.go:770 +0x124
github.com/hashicorp/terraform/internal/depsfile.(*ProviderLock).Version(...)
	github.com/hashicorp/terraform/internal/depsfile/locks.go:380
github.com/hashicorp/terraform/internal/command.(*ProvidersMirrorCommand).Run(0x1400084a380, {0x140001c2030?, 0x0?, 0x0?})
	github.com/hashicorp/terraform/internal/command/providers_mirror.go:164 +0x1204
github.com/hashicorp/cli.(*CLI).Run(0x14000856280)
	github.com/hashicorp/cli@v1.1.6/cli.go:265 +0x4a8
main.realMain()
	github.com/hashicorp/terraform/main.go:339 +0x18f8
main.main()
	github.com/hashicorp/terraform/main.go:64 +0x1c


Expected Behavior

Mirrors the providers

Actual Behavior

Crashes

Steps to Reproduce

terraform providers mirror .

Additional Context

Only seems to affect the cloudflare provider, other ones like null, random, aws all seem OK

References

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions