PrefectHQ / terraform-provider-prefect

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

Deployment error: json string value is null #289

Closed vnagaraj closed 1 month ago

vnagaraj commented 1 month ago

Community Note

Terraform Version

Affected Resource(s)

Terraform Configuration Files

resource "prefect_flow" "flow" {
  name         = "cowsay-flow"
  workspace_id = var.prefect_cloud_workspace_id
  tags         = ["tf-test"]
}
#
resource "prefect_deployment" "deployment" {
  name                     = "Cowsay Example Deployment"
  description              = "string"
  workspace_id             = var.prefect_cloud_workspace_id
  flow_id                  = prefect_flow.flow.id
  entrypoint               = "cowsay_example.py:cowsay_flow"
  tags                     = ["staging"]
  enforce_parameter_schema = false
  parameters = jsonencode({
    "creature" : "cow",
    "message"  :"Hello World!"
  })
  parameter_openapi_schema = jsonencode({
    "type" : "object",
    "properties" : {
      "creature" :  {"type": "string"}
      "message" : {"type": "string"}
    }
  })
  paused              = false
  storage_document_id = "eb5bbb9b-b499-4895-8932-8e366aa4b627"
  version             = "v1.1.1"
  work_pool_name      = "main"
  work_queue_name     = "default"
}

Debug Output

Panic Output

╷
│ Error: Normalized JSON Unmarshal Error
│ 
│   with module.flows.prefect_deployment.deployment,
│   on ../../modules/flows/main.tf line 7, in resource "prefect_deployment" "deployment":
│    7: resource "prefect_deployment" "deployment" {
│ 
│ json string value is null
╵
2024-10-28T21:47:39.083Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-10-28T21:47:39.085Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.opentofu.org/prefecthq/prefect/2.3.0/linux_amd64/terraform-provider-prefect_v2.3.0 pid=92
2024-10-28T21:47:39.086Z [DEBUG] provider: plugin exited
[01JBAFEXR70ME9JN0GVB6ES058] Unexpected exit code when applying changes: 1

Expected Behavior

Deployment should succeed

Actual Behavior

Failure as reported in Panic Output

Steps to Reproduce

  1. terraform plan
  2. terraform apply

References

https://github.com/PrefectHQ/terraform-provider-prefect/issues/238

mitchnielsen commented 1 month ago

Thanks for the report here, I'm working on replicating. What I've found so far is that you apparently need to specify all of the following:

They're optional, but it looks like we need to improve the way we unmarshal them in case they're not configured. Will look into it a bit more and put up a PR.

mitchnielsen commented 1 month ago

Thanks again @vnagaraj, we've just released https://github.com/PrefectHQ/terraform-provider-prefect/releases/tag/v2.5.1 which should address this. Please reach out if you run into any other issues.