Skip to content

Prevent rollback stage builder panics on empty stage lists#7002

Open
rootp1 wants to merge 1 commit into
pipe-cd:masterfrom
rootp1:fix/rollback-empty-stages
Open

Prevent rollback stage builder panics on empty stage lists#7002
rootp1 wants to merge 1 commit into
pipe-cd:masterfrom
rootp1:fix/rollback-empty-stages

Conversation

@rootp1

@rootp1 rootp1 commented Jul 10, 2026

Copy link
Copy Markdown

What this PR does:

Prevents rollback-enabled pipeline stage builders from panicking on empty stage lists in the Terraform, Kubernetes, Kubernetes multicluster, and Cloud Run piped v1 plugins.

Why we need it:

These builders currently call slices.MinFunc on an empty slice when rollback is enabled without configured stages, which crashes the builder instead of returning a controlled validation error.

Which issue(s) this PR fixes:

Fixes #7001

Summary

  • guard rollback stage synthesis when no stages are configured
  • return a stable validation error instead of panicking
  • add regression coverage for the empty-stage rollback case in each affected plugin

Linked Issue

Fixes #7001

What Changed

  • added empty-stage validation before computing rollback indices in the affected builders
  • updated multicluster and Cloud Run callers to propagate builder errors
  • extended existing table-driven tests to cover rollback-enabled empty stage lists

Verification

  • go -C pkg/app/pipedv1/plugin/terraform test ./deployment -run 'TestPlugin_BuildPipelineSyncStages' && go -C pkg/app/pipedv1/plugin/kubernetes test ./deployment -run 'Test_buildPipelineStages' && go -C pkg/app/pipedv1/plugin/kubernetes_multicluster test ./deployment -run 'Test_buildPipelineStages' && go -C pkg/app/pipedv1/plugin/cloudrun test ./deployment -run 'Test_buildPipelineStages' — passed
  • make build/go — passed
  • make check/gen/code — passed
  • make check — failed: yarn is not installed locally, so the repository-wide web build step in build/web could not run
  • make test/integration — failed: Docker is unavailable (/var/run/docker.sock missing) for the Firestore and MySQL integration suites
  • make check/dco — failed before the new commit because upstream master HEAD commit 25ae69937e55e8330bff96c34346718f3e5e7148 is missing a Signed-off-by line; this PR commit itself is signed off
  • make test/go MODULES=pkg/app/pipedv1/plugin/terraform,pkg/app/pipedv1/plugin/kubernetes,pkg/app/pipedv1/plugin/kubernetes_multicluster,pkg/app/pipedv1/plugin/cloudrun — not completed locally: the broader module-wide run did not finish in a reasonable time after entering the heavier Kubernetes suites, so the focused regression command above was used as the closest confirmed local alternative

Scope

  • Only the affected piped v1 rollback stage builders and their focused regression tests were changed.

Does this PR introduce a user-facing change?:

  • How are users affected by this change: rollback-enabled empty pipeline requests now return a validation error instead of crashing the builder path
  • Is this breaking change: No
  • How to migrate (if breaking change): Not applicable

Signed-off-by: rootp1 <arnav.iitr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-rollback stage builders panic when rollback is enabled but no stages are configured

1 participant