Skip to content

"Uncaught Error: No such module" using cloudflare_snippets #5017

@devin-purple

Description

@devin-purple

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

OpenTofu v1.8.7
on linux_amd64

  • provider registry.opentofu.org/cloudflare/cloudflare v5.0.0

Affected resource(s)

cloudflare_snippets

Terraform configuration files

resource "cloudflare_snippets" "xxx" {
  zone_id = yyy
  snippet_name = "xxx"
  files  = "export default { async fetch(request) {} }"
  metadata = {
    main_module = "snippet.js"
  }
}

Link to debug output

https://gist.github.com/devin-purple/80531791220402898a10cca86251bfad

Panic output

No response

Expected output

Snippet created

Actual output

╷
│ Error: failed to make http request
│ 
│   with cloudflare_snippets.tealium_client_info,
│   on tealium-client-ip.tf line 15, in resource "cloudflare_snippets" "tealium_client_info":
│   15: resource "cloudflare_snippets" "tealium_client_info" {
│ 
│ PUT "https://api.cloudflare.com/client/v4/zones/873d482250570299a000b59e656a46c9/snippets/tealium_client_info": 400 Bad Request {"success":false,"errors":[{"message":"Uncaught Error: No such module
│ \"33744/snippet.js\".\n  imported from \"main.js\"\n"}],"result":null}
│ 

Steps to reproduce

Use example TF.

Additional factoids

It seems like in the API request, the provider is sending Content-Disposition: form-data; name="files" instead of the actual name of the file.

In V4 you could send a map in files. In V5 it can only be a string.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.service/listCategorizes issue or PR as related to the List service.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