Skip to content

fix: remove connection_id default of 0 in dbtcloud_environment to prevent inconsistent result after apply #665

@trouze

Description

@trouze

Summary

dbtcloud_environment currently has Default: int64default.StaticInt64(0) on connection_id. This causes Terraform to report an "inconsistent result after apply" error when the API auto-assigns a connection to the environment (returns a non-zero value) but Terraform's plan expected 0.

Problem

When a user creates an environment without explicitly setting connection_id, the provider sends 0 to the API. The API may auto-assign a connection and return a non-zero connection_id in the response. Because the Terraform plan expected 0 (from the schema default) but the applied state contains the real ID, Terraform raises:

Error: Provider produced inconsistent result after apply

Fix

  • Remove Default: int64default.StaticInt64(0) from the connection_id attribute
  • In Create, only send connection_id to the API when the plan value is non-null and non-unknown; otherwise send 0
  • After create/read, always store the API's returned value (or null if nil) rather than defaulting to 0
  • Update Update to use null-safe comparison instead of direct value comparison for connection_id changes

Files

  • pkg/framework/objects/environment/schema.go — remove int64 default
  • pkg/framework/objects/environment/resource.go — null-safe create/update handling

Source

Developed on branch fix/provider-bug-wsargent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions