Menu

Catching Invalid Kafka Formats at Plan Time in the Materialize Terraform Provider
📰

Catching Invalid Kafka Formats at Plan Time in the Materialize Terraform Provider

DEV Community: terraform·Robert Markovski·about 3 hours ago
#qztE6EQm
#devtoterraform#devto#dev#format#schema
Reading 0:00
15s threshold

Moving an apply-time SQL error to a plan-time validation error, in a two-year-old issue.

Short answer

The materialize_source_kafka resource let you set format together with key_format , which Materialize does not accept, so terraform apply failed with a SQL syntax error. The fix adds ConflictsWith and RequiredWith rules to the schema, so Terraform rejects invalid combinations during plan. It was merged as PR #947 and closed issue #654 , which had been open since September 2024.

The problem

Issue #654 showed a Kafka source with both format { json = true } and key_format { json = true } . Applying it failed with:

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

Enter fullscreen mode

Exit fullscreen mode

The issue already proposed the fix: add a ConflictsWith so format can't be combined with key_format and value_format .

The fix

"format" : func ( ) * schema . Schema { . . . s .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.