auth0 / terraform-provider-auth0

The Auth0 Terraform Provider is the official plugin for managing Auth0 tenant configuration through the Terraform tool.
https://registry.terraform.io/providers/auth0/auth0/latest/docs
Mozilla Public License 2.0
165 stars 83 forks source link

Cannot update form after initial creation #1054

Open tcrawford-figure opened 1 week ago

tcrawford-figure commented 1 week ago

Checklist

Description

When modifying an existing auth0_form configuration and running apply I am receiving the following error, despite making no changes to any node ids:

Error: 400 Bad Request: Some nodes point to unknown node IDs

I also want to take time to point out that documentation in this area feels lackluster. I had to piece together what I can export from the Auth0 Forms UI and pull request bodies off the Auth0 API calls in the browser for form and flow updates in order to guess at what the correct configuration would even be in the first place for forms. After getting something successful after about 10 or so tries, I found a need to modify the form that I got in and find myself here.

Expectation

When I modify an auth0_form resource without modifying the nodes I expect it to update in place. Even if the node values are updated, I expect the form to override the existing node chain.

Reproduction

Given: I have updated a form configuration, like the coordinates for example.

When: I apply my plan

Then: My changes should be applied successfully.

Auth0 Terraform Provider version

1.7.1

Terraform version

1.7.5

aescudero-abbott commented 1 week ago

I'm also facing the same issue

msinstil commented 5 days ago

I'm also facing the same issue, this makes the forms unusable from terraform. Please fix!!

kushalshit27 commented 4 days ago

Thanks for opening the issue. Please use Terraform version 1.9.x for better support of jsonencode. If the issue persists, please share a sample auth0_form to investigate more.

msinstil commented 4 days ago

Thanks for opening the issue. Please use Terraform version 1.9.x for better support of jsonencode. If the issue persists, please share a sample auth0_form to investigate more.

Thanks @kushalshit27 for looking into this.

I am using Terraform v1.9.5 and Auth0 provider v1.7.1

Issue can be reproduced by taking the example form from Auth0 Provider docs (below), deploying it and then trying to add any new components to the nodes like another FIELD, BLOCK, HTML, RICH_TEXT etc.

# Example:
resource "auth0_form" "my_form" {
  name = "My KYC Form"

  start = jsonencode({
    coordinates = {
      x = 0
      y = 0
    }
    next_node = "step_ggeX"
  })
  nodes = jsonencode([{
    alias = "New step"
    config = {
      components = [{
        category = "FIELD"
        config = {
          max_length = 50
          min_length = 1
          multiline  = false
        }
        id        = "full_name"
        label     = "Your Name"
        required  = true
        sensitive = false
        type      = "TEXT"
        }, {
        category = "BLOCK"
        config = {
          text = "Continue"
        }
        id   = "next_button_3FbA"
        type = "NEXT_BUTTON"
      }]
      next_node = "$ending"
    }
    coordinates = {
      x = 500
      y = 0
    }
    id   = "step_ggeX"
    type = "STEP"
  }])
  ending = jsonencode({
    after_submit = {
      flow_id = "<my_flow_id>" # Altenative ways: (flow_id = auth0_flow.my_flow.id) or using terraform variables
    }
    coordinates = {
      x = 1250
      y = 0
    }
    resume_flow = true
  })

  style = jsonencode({
    css = "h1 {\n  color: white;\n  text-align: center;\n}"
  })

  translations = jsonencode({
    es = {
      components = {
        rich_text_uctu = {
          config = {
            content = "<h2>Help us verify your personal information</h2><p>We want to learn more about you so that we can validate and protect your account...</p>"
          }
        }
      }
      messages = {
        custom = {}
        errors = {
          ERR_ACCEPTANCE_REQUIRED = "Por favor, marca este campo para continuar."
        }
      }
    }
  })

  languages {
    default = "en"
    primary = "en"
  }
}
GDownes commented 4 days ago

I'm facing the same issue, having to update the name to get components updates to work