Why am I getting this Unsupported attribute error for template_variables?

I’m attempting to import a datadog dashboard into my project so we can have it terraformed.

I’ve copied the JSON from datadog, imported the file into my directory like so:

-infrastructure
     | 
      modules 
         | 
          datadog-dashboard 
             | 
              main.tf 
              api-health.json 
              variables.tf

here is my main.tf:

module "dashboard" {
    source = "git::git@gitlab.com:company/data-services/terrabox.git//modules/dynamic-datadog-dashboard?ref=tags/v2.1.13"
  
    title = "dashboard"
    layout_type = "ordered"
  
    template_variables = [
      {
        name = "pubsub_topic"
        tag = "topic_id"
      },
      {
        name = "pubsub_subscription"
        tag = "subscription_id"
      }
    ]
  
    template_variable_presets = [
      {
        name = "Development"
        ...
      }
    ]
  
    widgets = [
      {
        template = "${path.module}/api-health.json"
        context = {}
      },
    ...
    ]
  }

You can see where I’m importing my json widget for this module and I can see that I have template_variables defined.
But when I run my pipeline, here is the error that I’m getting(pasting whole error message)

terraform plan -out $PLANFILE -var-file ./environments/$TERRAFORM_ENV-$TERRAFORM_LOC/variables.tfvars
module.datadog_monitors.datadog_monitor.high_error_response_count: Refreshing state... [id=254743]
module.datadog_monitors.datadog_monitor.high_number_of_restarts: Refreshing state... [id=254739]
module.datadog_monitors.datadog_monitor.high_number_of_pods: Refreshing state... [id=254741]
module.datadog_monitors.datadog_monitor.p99_response_time: Refreshing state... [id=254740]
module.datadog_monitors.datadog_monitor.high_error_response_rate: Refreshing state... [id=254738]
module.datadog_monitors.datadog_monitor.cert_expiring: Refreshing state... [id=254744]
module.datadog_monitors.datadog_monitor.no_pods: Refreshing state... [id=254742]
module.account.module.service_account.google_service_account.service_accounts["api-sa-py-dev-na"]: Refreshing state... [id=projects/core-dev-na/serviceAccounts/api-sa-py-dev-na@dev-na-faba.iam.gserviceaccount.com]
module.datadog_monitors.datadog_monitor.high_error_response_composite: Refreshing state... [id=254745]
module.service_account.module.service_account.google_project_iam_member.project-roles["core-dev-na=>roles/secretmanager.secretAccessor"]: Refreshing state... [id=dev-na-faba/roles/secretmanager.secretAccessor/serviceaccount:api-sa-py-dev-na@dev-na-faba.iam.gserviceaccount.com]
module.service_account.module.service_account_workload_identity[0].google_service_account_iam_member.workload_identity_binding: Refreshing state... [id=projects/dev/serviceAccounts/api-sa-py-dev-na@dev-na.iam.gserviceaccount.com/roles/iam.workloadIdentityUser/serviceaccount:working-na-e22c.svc.id.goog[dev/api-sa]]
╷
│ Warning: Argument is deprecated
│ 
│   with module.datadog_monitors.datadog_monitor.cert_expiring,
│   on modules/datadog-monitors/main.tf line 177, in resource "datadog_monitor" "cert_expiring":
│  177:   new_host_delay = 300
│ 
│ Use `new_group_delay` except when setting `new_host_delay` to zero.
│ 
│ (and 2 more similar warnings elsewhere)
╵
╷
│ Error: Unsupported attribute
│ 
│   on .terraform/modules/datadog_dashboard.dashboard/modules/dynamic-datadog-dashboard/main.tf line 250, in locals:
│  250:         {for x in lookup(template, "template_variables", []): x.name => x.tag}
│ 
│ This object does not have an attribute named "tag".
╵
╷
│ Error: Unsupported attribute
│ 
│   on .terraform/modules/datadog_dashboard.dashboard/modules/dynamic-datadog-dashboard/main.tf line 250, in locals:
│  250:         {for x in lookup(template, "template_variables", []): x.name => x.tag}
│ 
│ This object does not have an attribute named "tag".
╵
╷
│ Error: Unsupported attribute
│ 
│   on .terraform/modules/datadog_dashboard.dashboard/modules/dynamic-datadog-dashboard/main.tf line 250, in locals:
│  250:         {for x in lookup(template, "template_variables", []): x.name => x.tag}
│ 
│ This object does not have an attribute named "tag".
╵
╷
│ Error: Unsupported attribute
│ 
│   on .terraform/modules/datadog_dashboard.dashboard/modules/dynamic-datadog-dashboard/main.tf line 250, in locals:
│  250:         {for x in lookup(template, "template_variables", []): x.name => x.tag}
│ 
│ This object does not have an attribute named "tag".
╵
╷
│ Error: Unsupported attribute
│ 
│   on .terraform/modules/datadog_dashboard.dashboard/modules/dynamic-datadog-dashboard/main.tf line 250, in locals:
│  250:         {for x in lookup(template, "template_variables", []): x.name => x.tag}
│ 
│ This object does not have an attribute named "tag".
╵
╷
│ Error: Unsupported attribute
│ 
│   on .terraform/modules/datadog_dashboard.dashboard/modules/dynamic-datadog-dashboard/main.tf line 250, in locals:
│  250:         {for x in lookup(template, "template_variables", []): x.name => x.tag}
│ 
│ This object does not have an attribute named "tag".
╵

This error is happening in my private module in gitlab so Its extremely hard to pinpoint what is going on. I tried removing the template_variables widget, same error. I’ve tried adding a tag to the imported json file but no luck.
When I look in that directory:

.terraform/modules/datadog_dashboard.dashboard/modules/dynamic-datadog-dashboard/main.tf line 250, in locals:
│  250:         {for x in lookup(template, "template_variables", []): x.name => x.tag}

Its just terraform state for that terraform configuration so it doesn’t show what part of the code is broken.

  ##########################
  ##  TEMPLATE VARIABLES  ##
  ##########################

  # Flatten out any templated variable configurations and override them with custom values if given
  template_variables = merge(merge([
    for template in local.templates:
        {for x in lookup(template, "template_variables", []): x.name => x.tag}
  ]...), {for x in var.template_variables: x.name => x.tag})

But am I not defining the template_variables correctly was a name and tag as shown above?