Skip to content

fix: refine dbtcloud_job type transition rules to avoid unnecessary resource replacement #666

@trouze

Description

@trouze

Summary

The current provider forces a resource replacement whenever job_type changes. This is overly aggressive — only certain transitions are actually restricted by the dbt Cloud API. The fix narrows the replacement requirement to just the transitions the API cannot handle in-place.

Current behavior

Any change to the job_type field (or the triggers that determine it) triggers RequiresReplace, destroying and recreating the job.

Desired behavior

Only transitions that the API restricts should force replacement:

Transition Requires replace?
CI ↔ non-CI Yes — API rejects this
Adaptive ↔ non-Adaptive Yes — API rejects this
Scheduled → Other No — in-place update
Other → Scheduled No — in-place update
Scheduled/Other → Merge No — in-place update
Merge → Scheduled/Other No — in-place update

Fix

Replace the blanket RequiresReplace plan modifier with logic that evaluates the old and new job types and only appends RequiresReplace for CI↔non-CI and Adaptive↔non-Adaptive transitions.

Tests added

  • TestAccDbtCloudJobResourceScheduledToOther — validates in-place update
  • Additional job type transition acceptance tests in resource_acceptance_job_type_transitions_test.go

Files

  • pkg/framework/objects/job/resource.go
  • pkg/framework/objects/job/resource_acceptance_job_type_transitions_test.go (new)

Source

Developed on branch fix/provider-bug-wsargent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions