Hi all, I am getting a 500 Internal Server Error s...
# ask-a-descoper
j
Hi all, I am getting a 500 Internal Server Error setting styles via the Terraform provider:
Copy code
│ Error: Error creating project
│ 
│   with module.employer_portal.descope_project.employer_portal,
│   on modules/employer-portal/main.tf line 186, in resource "descope_project" "employer_portal":
│  186: resource "descope_project" "employer_portal" {
│ 
│ [E113009] Failed to write entity data [Status-Code:500]
Even with an empty styles config, which matches the test case in the Terraform repository:
Copy code
{
  "componentsVersion": "2.0.291",
  "references": {},
  "styles": {
    "dark": {},
    "light": {}
  }
}
Since this is a 500, seems like it may be something on the Descope side? Any way to debug this further?
m
On the response error , can you get the CF-ray header ? And attach here ? Looping in @Nick Rodriguez and @Gil Shapira
👀 1
j
Is there a Terraform flag that will show that header? This is happening during a
terraform apply
and it doesn't show that detailed request/response info that I can see
m
which project id ?
Copy code
Request is malformed: Duplicate custom hostname found.
it seems there is another project with same CNAME domain
n
@Joe Einertson I believe you can use:
Copy code
export TF_LOG=DEBUG
export TF_LOG_PATH=terraform.log
terraform apply
Which should log the headers/payloads in a file named
terraform.log
j
OK, I have the log with payload, which I can send in a DM
I would be confused if it is a duplicate hostname because this project is using a new, unique hostname, as I can see in the Terraform plan. I also don't see any of our existing projects using the same hostname.
What is the best way forward here? Will it be easier if I open a support ticket?
n
Could you send over the terraform.log and the project id? Taking a look into this now.
✅ 1
i
Is this resolved? Can you guys share a working example of a descope_project with some of the more complex types
n
This has been resolved @Igor Miltchman. Is there something specific you are looking for regarding complex types?
i
I am looking for an example of what the expected input looks like. I put what I thought was correct
Copy code
styles = {
    data = jsonencode({
      styles = {
        custom-sso-dark = {
          "name" = "custom-sso-dark",
          "type" = "ssoSuite"
          globals = {
            fonts = {
              family = [
...
but got:
[E113009] Failed to write entity data [Status-Code:500]
j
This ended up working for us:
Copy code
styles = {
    data = jsonencode({
      componentsVersion = "2.1.3"
      references        = {}
      styles = {
        light = jsondecode(file("${path.module}/styles/light.json"))
        dark  = jsondecode(file("${path.module}/styles/dark.json"))
      }
    })
  }
We didn't want to mess with translating all the JSON to Terraform so we just kept it as JSON
gratitude thank you 1
g
Hi @Joe Einertson, I just want to make sure we're not missing anything here. I assume you have a source project you're editing the styles on. The easiest way to incorporate those styles into your
.tf
files is to export the theme from the Descope console and reference it in your
.tf
file. • Go to to this page in the Descope console: https://app.descope.com/styles • Export the
themes.json
file by clicking on the little up/down arrows (see screenshot). • Put the downloaded
themes.json
file somewhere next to your
.tf
file (or in a subdirectory). • Use
data = file("themes.json")
in your
.tf
file to incorporate it into your Terraform plan (or whatever path you used above). This should work properly and ensure you've sending the
styles
in the correct format. (sidenote: the
terraform
tool is usually smart enough to recognize that file actually JSON rather than simple text, and it behaves as if you used
jsonencode
, so you get a decent diff when there are
.tfstate
changes) Please let me know if this is still not working well enough for your use case or if you think we should improve something here.
gratitude thank you 1
🙏 1