terraform-provider-cloudflare icon indicating copy to clipboard operation
terraform-provider-cloudflare copied to clipboard

Page rule validation error message not being returned

Open brandonstrohmeyer opened this issue 2 years ago • 2 comments

Confirmation

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

Terraform and Cloudflare provider version

Terraform v1.1.9 on darwin_amd64

  • provider registry.terraform.io/cloudflare/cloudflare v3.13.0

Affected resource(s)

cloudflare_page_rule

Terraform configuration files

resource "cloudflare_page_rule" "this" {
  zone_id  = module.cloudflare_stro_debug.website.zone.id
  target   = "${module.cloudflare_stro_debug.website.zone.zone}/test"
  priority = 1

  actions {

    always_use_https = true

    cache_key_fields {
      header {}
      query_string {}
      user {}
      cookie {}
      host {}
    }
  }
}

Debug output

---[ RESPONSE ]--------------------------------------
HTTP/2.0 400 Bad Request
Connection: close
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Cf-Cache-Status: DYNAMIC
Cf-Ray: 7017f3c91ba9e3ca-ATL
Content-Type: application/json
Date: Mon, 25 Apr 2022 15:01:09 GMT
Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Expires: Sun, 25 Jan 1981 05:00:00 GMT
Pragma: no-cache
Server: cloudflare
Set-Cookie: __cflb=0H28vgHxwvgAQtjUGU4vq74ZFe3sNVUZaMRnT3FnvWR; SameSite=Lax; path=/; expires=Mon, 25-Apr-22 17:31:10 GMT; HttpOnly
Set-Cookie: __cfruid=fb89178db7f78f805459602d86f6c6a8d414fd04-1650898869; path=/; domain=.api.cloudflare.com; HttpOnly; Secure; SameSite=None
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN

{
 "success": false,
 "errors": [
  {
   "code": 1004,
   "message": "Page Rule validation failed: See messages for details."
  }
 ],
 "messages": [
  {
   "code": 1,
   "message": ".settings: \"always_use_https\" may not be used with \"any setting\"",
   "type": null
  }
 ],
 "result": null
}

Panic output

No response

Expected output

Expected messages field to be returned with error message

Actual output

Received vague error message:

│ Error: failed to create page rule: Page Rule validation failed: See messages for details. (1004)
│ 
│   with cloudflare_page_rule.this,
│   on stro-debug.tf line 108, in resource "cloudflare_page_rule" "this":
│  108: resource "cloudflare_page_rule" "this" {
│ 
╵

Steps to reproduce

  1. Build zone
  2. Apply a page rule that fails validation

Additional factoids

No response

References

No response

brandonstrohmeyer avatar Apr 25 '22 15:04 brandonstrohmeyer

Thank you for reporting this issue! For maintainers to dig into issues it is required that all issues include the entirety of TF_LOG=DEBUG output to be provided. The only parts that should be redacted are your user credentials in the X-Auth-Key, X-Auth-Email and Authorization HTTP headers. Details such as zone or account identifiers are not considered sensitive but can be redacted if you are very cautious. This log file provides additional context from Terraform, the provider and the Cloudflare API that helps in debugging issues. Without it, maintainers are very limited in what they can do and may hamper diagnosis efforts.

This issue has been marked with triage/needs-information and is unlikely to receive maintainer attention until the log file is provided making this a complete bug report.

github-actions[bot] avatar Apr 25 '22 15:04 github-actions[bot]

Please fix this asap, this is making working with page rules a real pain.

Few weeks later update: please have pity for our poor souls

etienne-napoleone avatar Jun 12 '22 14:06 etienne-napoleone

We have a very hard time at pulumi-cloudflare because of this.

roger-5899 avatar Oct 15 '22 00:10 roger-5899

Assume that cloudflare-go needs to be bumped to v0.53.0 as well?

reedloden avatar Oct 18 '22 06:10 reedloden

yes, this requires the upstream release and then it will be included in the provider.

jacobbednarz avatar Oct 18 '22 07:10 jacobbednarz