Skip to content

Provider allows invalid environment schema/dataset names without validation #514

@TimKlense

Description

@TimKlense

Describe the bug / feature request

The dbt Cloud Terraform provider lets you create credentials/environments with invalid schema (or dataset) names. The apply succeeds, but downstream operations (dbt runs, object creation) fail at runtime due to the invalid name. This likely needs input validation in the provider at plan/apply time.

Error message

N/A - Validation checks needed

Resource configuration

The relevant resource configuration (sanitised so it doesn't contain sensitive data)

Likely affected resources (tbh I don't know the full list of validation checks for each adapter & schema. So someone would need to verify.)

  • dbtcloud_databricks_credential.schema
  • dbtcloud_snowflake_credential.schema
  • dbtcloud_bigquery_credential.dataset
  • dbtcloud_redshift_credential.default_schema
  • dbtcloud_postgres_credential.default_schema
  • dbtcloud_starburst_credential.schema
  • dbtcloud_teradata_credential.schema
  • dbtcloud_synapse_credential.schema
  • dbtcloud_fabric_credential.schema
  • dbtcloud_athena_credential.schema

Minimal TF config # take note of the "/" in the schema for dbtcloud_databricks_credential

terraform {
  required_providers {
    dbtcloud = {
      source  = "dbt-labs/dbtcloud"
      version = "~> 1.0"
    }
  }
}

provider "dbtcloud" {
  account_id = var.dbt_account_id
  token      = var.dbt_token
  host_url   = var.dbt_host_url
}

resource "dbtcloud_project" "example" {
  name = "Validation Test"
}

resource "dbtcloud_databricks_credential" "invalid_schema" {
  project_id   = dbtcloud_project.example.id
  token        = "placeholder"
  schema       = "dbt_prod_schema_databricks_user/token" # invalid: contains '/'
  adapter_type = "databricks"
  catalog      = "main"
}

Steps to reproduce

  1. Apply the configuration above.
  2. Observe that Terraform apply succeeds and the credential/resource is created in dbt Cloud.
  3. Attempt to run a job that uses this credential/environment.
  4. The run fails at runtime due to the invalid schema name

No validation error at plan/apply. The invalid value is accepted and only surfaces as a runtime failure later.

Note: here's what dbt Cloud displays as a validation check/msg

Image

It's possible you'd want to check their entire validation logic for the form (if you'd want to match their logic)

Expected behavior

  • The provider should validate schema/dataset names per adapter and fail early with a helpful error message during plan/apply when the value is invalid.

Config (please complete the following information):

  • dbt Cloud provider version: 1.2.1

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions