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

Pages does not update project when removing environment variables #2639

Open
2 tasks done
Cyb3r-Jak3 opened this issue Jul 29, 2023 · 3 comments
Open
2 tasks done

Pages does not update project when removing environment variables #2639

Cyb3r-Jak3 opened this issue Jul 29, 2023 · 3 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. service/pages Categorizes issue or PR as related to the Pages service. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. workflow/synced

Comments

@Cyb3r-Jak3
Copy link
Contributor

Cyb3r-Jak3 commented Jul 29, 2023

Confirmation

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

Terraform and Cloudflare provider version

Terraform v1.5.0
on windows_amd64

  • provider registry.terraform.io/1password/onepassword v1.1.4
  • provider registry.terraform.io/cloudflare/cloudflare v4.11.0
  • provider registry.terraform.io/hashicorp/http v3.4.0

Affected resource(s)

pages_project

Terraform configuration files

resource "cloudflare_pages_project" "test-project" {
  account_id        = var.account_id
  name              = "test-project"
  production_branch = "main"
  deployment_configs {
    preview {
      always_use_latest_compatibility_date = true
      fail_open                            = false
      environment_variables = {
        NODE_VERSION   = "18"
      }
      placement {}
    }
    production {
      fail_open = false
      environment_variables = {
        NODE_VERSION   = "18"
        PYTHON_VERSION = "3.7"
      }
      placement {}
    }
  }
}

Link to debug output

https://gist.github.com/Cyb3r-Jak3/57af688997416a9027b10f9141076b76

Panic output

No response

Expected output

That deleting the environment variable of PYTHON_VERSION removes it from the project

Actual output

The variable still set.

Steps to reproduce

  1. Create a pages project with an environment variable
  2. Delete the environment variable
  3. The environment variable stays

Additional factoids

It appears to be an issue with the backend API, as the PATCH request has the variable removed, but the response still has it. Looking at how the dashboard handles it, it sets the variable as a null value.

References

No response

@Cyb3r-Jak3 Cyb3r-Jak3 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 Jul 29, 2023
@github-actions
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 Jul 29, 2023
@jacobbednarz
Copy link
Member

what you're seeing here is a consequence of the service using a HTTP PATCH. as HTTP schemantics for PATCH are (generally) "only modify what changes in the payload" you can't really know what to remove. that is where a PUT request is usually a better choice which gives you the entirety of the resource picture.

@WalshyDev is this something you can address in the service itself when parameters are removed from the env var payloads?

@jacobbednarz jacobbednarz added triage/accepted Indicates an issue or PR is ready to be actively worked on. service/pages Categorizes issue or PR as related to the Pages service. labels Aug 2, 2023
@WalshyDev
Copy link
Member

Yeah as mentioned, this is a PATCH not PUT so expected from an API perspective.

imo the service should not change here. { env_vars: { ENV: {} } } is a lot less explicit than { env_vars: { ENV: null } } for removal
I'd say that an empty env object is expected to not change (just like an empty root project does not change).

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. service/pages Categorizes issue or PR as related to the Pages service. triage/accepted Indicates an issue or PR is ready to be actively worked on. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. workflow/synced
Projects
None yet
Development

No branches or pull requests

3 participants