PrefectHQ / terraform-provider-prefect

Terraform Provider for Prefect Cloud
https://registry.terraform.io/providers/PrefectHQ/prefect/latest/docs
Apache License 2.0
29 stars 12 forks source link

422 Response on Account resource update #227

Closed robfreedy closed 2 weeks ago

robfreedy commented 2 weeks ago

Community Note

Terraform Version

Terraform v1.7.5
on darwin_arm64
+ provider registry.terraform.io/prefecthq/prefect v2.0.0

Affected Resource(s)

Terraform Configuration Files

# Copy-paste your Terraform configurations here.
#
# For large Terraform configs, please use a service like Dropbox and share a link to the ZIP file.
# For security, you can also encrypt the files using our GPG public key:
#    https://www.hashicorp.com/security
#
# If reproducing the bug involves modifying the config file (e.g., apply a config,
# change a value, apply the config again, see the bug), then please include both:
# * the version of the config before the change, and
# * the version of the config after the change.
resource "prefect_account" "test_tf_account" {
  handle        = "robertprefectio"
  name          = "robertprefectio"
  billing_email = "test@prefect.io"
  allow_public_workspaces = false
}

Debug Output

prefect_account.test_tf_account: Modifying... [id=a0461d35-5351-4284-bb93-de0975f46b7d]
╷
│ Error: Error during update Account
│ 
│   with prefect_account.test_tf_account,
│   on resource.tf line 9, in resource "prefect_account" "test_tf_account":
│    9: resource "prefect_account" "test_tf_account" {
│ 
│ Could not update Account, unexpected error: status code 422 Unprocessable Entity, error={"exception_message":"Invalid request
│ received.","exception_detail":[{"loc":["body","allow_public_workspaces"],"msg":"extra fields not
│ permitted","type":"value_error.extra"}],"request_body":{"name":"robertprefectio","handle":"robertprefectio","location":null,"link":null,"auth_expiration_seconds":null,"allow_public_workspaces":false,"billing_email":"test@prefect.io"}}

Panic Output

Expected Behavior

Prefect account should be updated with the billing_email and allow_public_workspaces fields.

Actual Behavior

Unable to update Prefect account fields due to 422 error on tf apply.

Steps to Reproduce

  1. terraform import prefect_account.test_tf_account a0461d35-5351-4284-bb93-de0975f46b7d
  2. Specify prefect_account resource (see code above)
  3. terraform apply

Important Factoids

References

Looks like the 'allow_public_workspaces' field for the update accounts API call is under a 'settings' field now. Most likely just needs a quick update to reflect the new nested structure.

image
parkedwards commented 2 weeks ago

thanks @robfreedy - we'll take a look

mitchnielsen commented 2 weeks ago

@robfreedy - this should be fixed now 👍🏼

We haven't cut a release yet, but you can:

  1. Clone this project and switch to the directory
  2. Run go install
  3. Copy the ~/.terraformrc file to your system
  4. Run your terraform commands
mitchnielsen commented 2 weeks ago

@parkedwards - is it worth considering a patch release here? If so, what does that process look like? (I can kick it off)