fix: keep successful plans applyable when automerge blocks on a sibling project error#6698
Open
azotamiota wants to merge 3 commits into
Open
Conversation
… error When automerge is enabled and a multi-project plan run has one project error out, Atlantis was deleting the plan and lock for every project in the run, including ones that planned successfully. This made it impossible to apply a project that planned cleanly until the failing project was fixed and everything was replanned from scratch. Automerge itself already refuses to merge until every project tracked on the pull request shows an Applied status, so gating on this specific failure by wiping successful plans was unnecessary. Stop deleting plans and locks after a partial failure so a successful project can still be applied on its own while a sibling project is fixed and replanned. Assisted-by: Claude <noreply@anthropic.com> Signed-off-by: Norbert Majer <norbert.majer@getchip.uk>
added 2 commits
July 24, 2026 23:02
…-plans-on-partial-automerge-failure Signed-off-by: Norbert Majer <norbert.majer@getchip.uk> # Conflicts: # server/events/command_runner_test.go # server/events/plan_command_runner.go
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.
What
Stops Atlantis from deleting a project's saved plan and lock when automerge is enabled and a different project's
atlantis planerrors. A project whose plan succeeded can now be applied on its own (atlantis apply -p <path>) while a sibling project's plan is fixed and replanned, instead of both being wiped.server/events/plan_command_runner.go: removed the post-rundeletePlansAndPlanLocks+result.PlansDeleted = truestep in bothrunAutoplan()andrun()that ran whenever automerge was enabled and the batch had any error. No replacement gate is added — a successful project's plan/lock is simply left alone.server/events/command_runner_test.go: updatedTestRunAutoplanCommandWithError_DeletePlans→TestRunAutoplanCommandWithError_KeepsSuccessfulPlans, assertingDeletePlansis now called once (the pre-run stale-plan discard) instead of twice.Automerge itself is unaffected by this change:
AutoMerger.automerge()inserver/events/automerger.goalready refuses to merge until every project tracked on the pull request has anAppliedstatus, so the extra plan-wiping under automerge+error was blocking a valid recovery workflow without adding any real safety.Why / relation to #3002 and #6613
This closes #3002 ("Only delete the plan that failed when automerge is enabled").
#6613 also targets #3002 and independently arrives at "keep successful plans on disk," plus adds
atlantis plan --failedto re-plan just the broken projects — a genuinely useful, complementary addition this PR does not attempt to duplicate.However, testing against #6613 shows it doesn't unblock the specific workflow this PR is for. #6613 adds an unconditional gate at the top of
ApplyCommandRunner.Run():ctx.ErroredPlanProjects()inspects every project tracked on the whole pull request, not just the one(s) targeted by the current command. So even a scopedatlantis apply -p <successful-project-path>is rejected as long as any other project in the PR has an errored plan — which reintroduces the "can't touch anything until everything is fixed" problem for targeted applies, just via a hard block instead of file deletion.This PR takes the narrower approach of not adding any new apply-time gate: a project's plan is either there (because it planned successfully) or it isn't, and
-p/-d/-w-scoped applies behave exactly as they already do for any other single-project apply. It can coexist withatlantis plan --failedfrom #6613 if that lands separately, or the apply-blocking behavior there could be re-scoped to the command's targeted project(s) — happy to help with either depending on maintainer preference.Scenario this enables
atlantis apply -p <project-2-path>works immediately instead of failing with "plan was not saved" (or, under feat: keep plans on partial failure, add 'atlantis plan --failed' #6613 as currently written, a hard apply-block).Applied.Test plan
go build ./...go test ./server/events/...(full package passes, including the updated test)Assisted-by: Claude noreply@anthropic.com