Summary
Three tightly coupled changes to dbtcloud_job that should ship together: a new attribute for controlling State-Aware Orchestration (SAO), and two bug fixes for CI/Merge jobs that were causing API errors and silent data loss.
1. New attribute: cost_optimization_features
Adds a cost_optimization_features set attribute as the preferred way to enable SAO, replacing the existing force_node_selection bool (which is now deprecated).
resource "dbtcloud_job" "example" {
name = "Production Run"
dbt_version = "latest-fusion" # required for SAO
execute_steps = ["dbt build"]
# New way — enable SAO
cost_optimization_features = ["state_aware_orchestration"]
# Old way (deprecated, still works)
# force_node_selection = false
}
Valid values for cost_optimization_features: state_aware_orchestration
2. Bug fix: CI/Merge jobs no longer error with SAO validation (405)
Problem: The API rejects any explicit force_node_selection value for CI/Merge jobs with 405: State aware orchestration is not available for CI or Merge jobs. The provider was sending force_node_selection=false for these jobs even when the user hadn't set it, because the field was Computed: true and defaulted to unknown.
Fix: Skip sending force_node_selection entirely when the plan value is null or unknown.
3. Bug fix: CI/Merge jobs no longer silently drop deferring_environment_id
Problem: CreateJob contained logic that explicitly zeroed out deferring_environment_id and deferring_job_id for CI/Merge jobs. This is incorrect — deferral for artifact access is valid and separate from SAO.
Fix: Remove the zeroing logic. CI/Merge jobs now correctly preserve deferring_environment_id.
Tests added
TestAccDbtCloudJobResourceCIWithDeferral
TestAccDbtCloudJobResourceMergeWithDeferral
TestAccDbtCloudJobResourceCINoForceNodeSelection
TestAccDbtCloudJobResourceMergeNoForceNodeSelection
TestAccDbtCloudJobResourceCostOptimizationFeatures
Files
pkg/dbt_cloud/job.go
pkg/framework/objects/job/model.go
pkg/framework/objects/job/resource.go
pkg/framework/objects/job/schema.go
pkg/framework/objects/job/resource_acceptance_cost_optimization_test.go (new)
Source
Developed on branch fix/provider-bug-wsargent. PR description with full detail is in PR_DESCRIPTION.md on that branch.
Summary
Three tightly coupled changes to
dbtcloud_jobthat should ship together: a new attribute for controlling State-Aware Orchestration (SAO), and two bug fixes for CI/Merge jobs that were causing API errors and silent data loss.1. New attribute:
cost_optimization_featuresAdds a
cost_optimization_featuresset attribute as the preferred way to enable SAO, replacing the existingforce_node_selectionbool (which is now deprecated).Valid values for
cost_optimization_features:state_aware_orchestration2. Bug fix: CI/Merge jobs no longer error with SAO validation (405)
Problem: The API rejects any explicit
force_node_selectionvalue for CI/Merge jobs with405: State aware orchestration is not available for CI or Merge jobs. The provider was sendingforce_node_selection=falsefor these jobs even when the user hadn't set it, because the field wasComputed: trueand defaulted to unknown.Fix: Skip sending
force_node_selectionentirely when the plan value is null or unknown.3. Bug fix: CI/Merge jobs no longer silently drop
deferring_environment_idProblem:
CreateJobcontained logic that explicitly zeroed outdeferring_environment_idanddeferring_job_idfor CI/Merge jobs. This is incorrect — deferral for artifact access is valid and separate from SAO.Fix: Remove the zeroing logic. CI/Merge jobs now correctly preserve
deferring_environment_id.Tests added
TestAccDbtCloudJobResourceCIWithDeferralTestAccDbtCloudJobResourceMergeWithDeferralTestAccDbtCloudJobResourceCINoForceNodeSelectionTestAccDbtCloudJobResourceMergeNoForceNodeSelectionTestAccDbtCloudJobResourceCostOptimizationFeaturesFiles
pkg/dbt_cloud/job.gopkg/framework/objects/job/model.gopkg/framework/objects/job/resource.gopkg/framework/objects/job/schema.gopkg/framework/objects/job/resource_acceptance_cost_optimization_test.go(new)Source
Developed on branch
fix/provider-bug-wsargent. PR description with full detail is inPR_DESCRIPTION.mdon that branch.