Skip to content

cloudflare_worker - Provider outputs error after js script update #6303

@albertocrj

Description

@albertocrj

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

  • provider registry.terraform.io/cloudflare/cloudflare v5.11.0

Affected resource(s)

cloudflare_worker_version.sites_estaticos

Terraform configuration files

resource "cloudflare_worker" "sites_estaticos" {
  account_id = var.cloudflare_account_id
  name = "sites-estaticos-test"
  observability = {
    enabled = false
  }
}

resource "cloudflare_worker_version" "sites_estaticos" {
  account_id = var.cloudflare_account_id
  worker_id = cloudflare_worker.sites_estaticos.id
  compatibility_date = "2025-10-03"
  main_module = "sites-estaticos"
  lifecycle {
    create_before_destroy = true
  }
  
  modules = [
    {
      name = "sites-estaticos"
      content_type = "application/javascript+module"
      content_file = abspath("${path.module}/workers/sites-tests.js")
    }
  ]
}

resource "cloudflare_workers_deployment" "sites_estaticos" {
  account_id = var.cloudflare_account_id
  script_name = cloudflare_worker.sites_estaticos.name
  strategy = "percentage"
  versions = [{
    percentage = 100
    version_id = cloudflare_worker_version.sites_estaticos.id
  }]
}

Link to debug output

--

Panic output

Error: Provider produced inconsistent result after apply

│ When applying changes to cloudflare_worker_version.sites_estaticos, provider "provider["registry.terraform.io/cloudflare/cloudflare"]" produced an unexpected new value: .modules: planned set element
│ cty.ObjectVal(map[string]cty.Value{"content_file":cty.StringVal("./workers/sites-tests.js"),
│ "content_sha256":cty.StringVal("15dedebb46f3083dc40006a2184ba36fb01a16da32fbdebdd534242b36c30d6f"), "content_type":cty.StringVal("application/javascript+module"), "name":cty.StringVal("sites-estaticos")})
│ does not correlate with any element in actual.

│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

2025-10-03T11:22:28.456-0300 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2025-10-03T11:22:28.457-0300 [INFO] provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/cloudflare/cloudflare/5.11.0/linux_amd64/terraform-provider-cloudflare_v5.11.0 id=68739
2025-10-03T11:22:28.457-0300 [DEBUG] provider: plugin exited

Expected output

The js script to be updated

Actual output

│ Error: Provider produced inconsistent result after apply

│ When applying changes to cloudflare_worker_version.sites_estaticos, provider "provider["registry.terraform.io/cloudflare/cloudflare"]" produced an unexpected new value: .modules: planned set element
│ cty.ObjectVal(map[string]cty.Value{"content_file":cty.StringVal("./workers/sites-tests.js"),
│ "content_sha256":cty.StringVal("15dedebb46f3083dc40006a2184ba36fb01a16da32fbdebdd534242b36c30d6f"), "content_type":cty.StringVal("application/javascript+module"), "name":cty.StringVal("sites-estaticos")})
│ does not correlate with any element in actual.

│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Steps to reproduce

  1. Create a cloudflare_worker
  2. Create cloudflare_worker_version
  3. Create cloudflare_workers_deployment
  4. Apply the resources
  5. Try to update the js script
  6. Apply the changes

Additional factoids

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.version/5Categorizes issue or PR as related to version 5 of the provider.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions