MaterializeInc / terraform-provider-materialize

A Terraform provider for Materialize
https://registry.terraform.io/providers/MaterializeInc/materialize
Mozilla Public License 2.0
11 stars 8 forks source link

Bug: `materialize_source_kafka` allows incompatible `format` and `key_format` options #654

Open bobbyiliev opened 1 month ago

bobbyiliev commented 1 month ago

What version of the Materialize Terraform provider are you using?

v0.8.8

What version of the Terraform CLI are you using?

v1.9.5

What version of Materialize are you using?

v0.117.0

What is the issue?

@sthm noticed that the Terraform provider allows you to specify format and ket_format options which are incompatible:

image

This results in the following error:

│ Error: ERROR: Expected end of statement, found KEY (SQLSTATE 42601)

To reproduce:

resource "materialize_source_kafka" "json_source" {
  name         = "avro_source"
  topic        = confluent_kafka_topic.topic.topic_name
  schema_name  = materialize_schema.public.name
  cluster_name = materialize_cluster.default.name
  kafka_connection {
    schema_name = materialize_schema.public.name
    name        = materialize_connection_kafka.confluent_cloud.name
  }
  format {
    json = true
  }
  key_format {
    json = true
  }
  envelope {
    upsert = true
  }
  include_key = true
}

We should extend the schema for the Kafka source and include a ConflictsWith for the format attribute so that it can not be used together with the key_format and value_format attributes.

sthm commented 1 month ago

Thanks for filing the issue, Bobby! In addition to the conflict between format and key_format, the usage of

  format {
    json = true
  }

actually requires key_format and value_formatto be used.