direct: Fix phantom diffs from depends_on reordering in job tasks#4990
Open
direct: Fix phantom diffs from depends_on reordering in job tasks#4990
Conversation
denik
added a commit
that referenced
this pull request
Apr 16, 2026
Approval status: pending
|
Register tasks[*].depends_on and tasks[*].for_each_task.task.depends_on as keyed slices so task dependencies are diffed by task_key rather than by position. Also fix pathToPattern in structdiff to treat key-value path nodes as [*] wildcards, enabling nested keyed-slice patterns to match correctly. Co-authored-by: Isaac
Test that reordered depends_on arrays within job tasks produce no phantom diffs when using the tasks[*].depends_on key function. Task: 001.md Co-authored-by: Isaac
Simulates real API behavior where depends_on entries are returned in a different order than submitted. Adds an acceptance test that verifies bundle plan shows 0 changes after deploy despite the reordering.
The depends_on reordering fix is in the direct engine. The terraform engine handles ordering through its provider, so the acceptance test should only run with the direct engine. Task: 001.md Co-authored-by: Isaac
Co-authored-by: Isaac
Adds a template config with tasks that use depends_on to verify depends_on handling is stable across deploy/redeploy cycles.
Remove the dedicated acceptance/bundle/resources/jobs/depends-on-reorder/ test since the invariant test config job_with_depends_on.yml.tmpl covers the same scenario through the no_drift and continue_293 variants. Exclude job_with_depends_on from the migrate variant because terraform does not apply keyed-slice ordering for depends_on. Task: 002.md Co-authored-by: Isaac
Remove the EnvMatrixExclude for job_with_depends_on.yml.tmpl from the migration invariant test. Instead, pass --noplancheck to the migrate command for this config, since Terraform's plan detects false drift due to depends_on ordering differences. The post-migration plan check (using direct engine) validates no drift correctly because the direct engine handles keyed-slice ordering. Task: 003.md Co-authored-by: Isaac
The terraform provider sorts depends_on entries by task_key on Read (see terraform-provider-databricks PR #3000). Since depends_on uses TypeList (order-sensitive), terraform plan detects positional differences when the config order doesn't match the sorted state order. Fix by sorting depends_on in the CLI's terraform conversion, matching the provider's behavior. This removes the --noplancheck workaround from the migration invariant test. Task: 004.md
Remove the sortDependsOn function and its usage in convertJobResource. The terraform provider already sorts depends_on by task_key on Read, so fixing the ordering in the CLI is unnecessary complexity. Instead, restore --noplancheck for job_with_depends_on in the migrate invariant test with a detailed comment explaining the false drift: the provider sorts depends_on by task_key using TypeList (order-sensitive), so terraform plan reports positional differences when the config order doesn't match the sorted state. Task: 005.md Co-authored-by: Isaac
d91cd1b to
ef3cfc8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Fix phantom diffs in
bundle plancaused by the Jobs API returningdepends_onarrays in a different order than submitted. Bothtasks[*].depends_onandtasks[*].for_each_task.task.depends_onare handled.Why
After a deploy with the direct engine, every subsequent
bundle planshowed spuriousdepends_onupdates even though nothing changed, creating a perpetual deploy-plan-update cycle.Tests
depends_onkeyed-slice diffing (reorder, field change, add, remove).depends_onbytask_keyto simulate real API reordering.depends-on-reorder, direct-only) verifies deploy followed by plan reports no changes.