Skip to content

fix: deploy/delete deps try to connect to later stages#557

Merged
ilya-lesikov merged 1 commit intomainfrom
fix/deploy-and-delete-deps-never-connect-to-another-stage
Feb 4, 2026
Merged

fix: deploy/delete deps try to connect to later stages#557
ilya-lesikov merged 1 commit intomainfrom
fix/deploy-and-delete-deps-never-connect-to-another-stage

Conversation

@ilya-lesikov
Copy link
Member

@ilya-lesikov ilya-lesikov commented Feb 4, 2026

Summary by Bito

This PR fixes a bug in the plan building process where deploy and delete dependency connections were attempting to link to operations in later stages, which could lead to incorrect execution order and potential failures in resource management. The modifications ensure dependencies are resolved within the same stage, enhancing the reliability of multi-stage deployments.

Detailed Changes
  • Updates function signatures for connectInternalDeployDependencies and connectInternalDeleteDependencies in plan_build.go to include additional parameters for cross-referencing resources across deploy and delete operations, enabling stage-aware dependency resolution.
  • Replaces global operation searches with stage-specific finder functions to ensure dependencies are resolved within the same stage, preventing connections to later stages.
  • Adds support for ResourceStateAbsent in deploy dependencies by introducing findTrackAbsenceOpInStage, allowing deploy operations to depend on absence tracking in the same stage.
  • Removes obsolete functions and adjusts imports, simplifying the API and removing redundant code.

@bito-code-review
Copy link

bito-code-review bot commented Feb 4, 2026

Code Review Agent Run #fe3c3f

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: fdc017d..fdc017d
    • internal/plan/plan_build.go
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Golangci-lint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at ilya.lesikov@flant.com.

Documentation & Help

AI Code Review powered by Bito Logo

Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
@ilya-lesikov ilya-lesikov force-pushed the fix/deploy-and-delete-deps-never-connect-to-another-stage branch from fdc017d to f466e15 Compare February 4, 2026 12:25
@ilya-lesikov ilya-lesikov merged commit 3823686 into main Feb 4, 2026
8 checks passed
@ilya-lesikov ilya-lesikov deleted the fix/deploy-and-delete-deps-never-connect-to-another-stage branch February 4, 2026 12:42
Copy link

@bito-code-review bito-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Agent Run #16fded

Actionable Suggestions - 3
  • internal/plan/plan_build.go - 3
Review Details
  • Files reviewed - 1 · Commit Range: f466e15..f466e15
    • internal/plan/plan_build.go
  • Files skipped - 1
    • CONTRIBUTING.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Golangci-lint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at ilya.lesikov@flant.com.

Documentation & Help

AI Code Review powered by Bito Logo

if candidate.MustInstall == ResourceInstallTypeNone ||
candidate.Stage != sourceStage ||
!dep.Match(candidate.ResourceMeta) ||
(match != nil && candidate.Iteration >= match.Iteration) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect max iteration selection

The condition skips candidates with higher iterations, potentially selecting the wrong operation for dependencies. This could lead to incorrect deployment order if multiple iterations exist.

Code suggestion
Check the AI-generated fix before applying
 -	for _, candidate := range instInfos {
 -		if candidate.MustInstall == ResourceInstallTypeNone ||
 -			candidate.Stage != sourceStage ||
 -			!dep.Match(candidate.ResourceMeta) ||
 -			(match != nil && candidate.Iteration >= match.Iteration) {
 -			continue
 -		}
 -
 -		match = candidate
 -	}
 +	for _, candidate := range instInfos {
 +		if candidate.MustInstall == ResourceInstallTypeNone ||
 -			candidate.Stage != sourceStage ||
 -			!dep.Match(candidate.ResourceMeta) {
 -			continue
 -		}
 -
 -		if match == nil || candidate.Iteration > match.Iteration {
 -			match = candidate
 -		}
 -	}

Code Review Run #16fded


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

!dep.Match(candidate.ResourceMeta) ||
(match != nil && candidate.Iteration >= match.Iteration) {
continue
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect max iteration selection

The condition skips candidates with higher iterations, potentially selecting the wrong operation for readiness tracking dependencies. This could lead to incorrect deployment order if multiple iterations exist.

Code suggestion
Check the AI-generated fix before applying
 - func findTrackReadinessOpInStage(plan *Plan, instInfos []*InstallableResourceInfo, dep *resource.InternalDependency, sourceStage common.Stage) (*Operation, bool) {
 - 	var match *InstallableResourceInfo
 - 	for _, candidate := range instInfos {
 - 		if !candidate.MustTrackReadiness ||
 - 			candidate.Stage != sourceStage ||
 - 			!dep.Match(candidate.ResourceMeta) ||
 - 			(match != nil && candidate.Iteration >= match.Iteration) {
 - 			continue
 - 		}
 - 
 - 		match = candidate
 - 	}
 - 
 - 	if match == nil {
 - 		return nil, false
 - 	}
 - 
 - 	topID := OperationID(OperationTypeTrackReadiness, OperationVersionTrackReadiness, OperationIteration(match.Iteration), match.ID())
 - 
 - 	return plan.Operation(opID)
 - }
 + func findTrackReadinessOpInStage(plan *Plan, instInfos []*InstallableResourceInfo, dep *resource.InternalDependency, sourceStage common.Stage) (*Operation, bool) {
 + 	var match *InstallableResourceInfo
 + 	for _, candidate := range instInfos {
 + 		if !candidate.MustTrackReadiness ||
 - 			candidate.Stage != sourceStage ||
 - 			!dep.Match(candidate.ResourceMeta) {
 - 			continue
 - 		}
 - 
 - 		if match == nil || candidate.Iteration > match.Iteration {
 - 			match = candidate
 - 		}
 - 	}
 - 
 - 	if match == nil {
 - 		return nil, false
 - 	}
 - 
 - 	opID := OperationID(OperationTypeTrackReadiness, OperationVersionTrackReadiness, OperationIteration(match.Iteration), match.ID())
 - 
 - 	return plan.Operation(opID)
 - }

Code Review Run #16fded


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

if !candidate.MustDeleteOnSuccessfulInstall ||
candidate.StageDeleteOnSuccessfulInstall != sourceStage ||
!dep.Match(candidate.ResourceMeta) ||
(match != nil && candidate.Iteration >= match.Iteration) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect max iteration selection

The condition skips candidates with higher iterations, potentially selecting the wrong operation for absence tracking dependencies. This could lead to incorrect deployment order if multiple iterations exist.

Code suggestion
Check the AI-generated fix before applying
 -		if !candidate.MustDeleteOnSuccessfulInstall ||
 -			candidate.StageDeleteOnSuccessfulInstall != sourceStage ||
 -			!dep.Match(candidate.ResourceMeta) ||
 -			(match != nil && candidate.Iteration >= match.Iteration) {
 -			continue
 -		}
 -
 -		match = candidate
 +		if !candidate.MustDeleteOnSuccessfulInstall ||
 -			candidate.StageDeleteOnSuccessfulInstall != sourceStage ||
 -			!dep.Match(candidate.ResourceMeta) {
 -			continue
 -		}
 -
 -		if match == nil || candidate.Iteration > match.Iteration {
 -			match = candidate
 -		}

Code Review Run #16fded


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant