Skip to content

🐛 (CLI): Fix redundant guard and swallowed checkout error in alpha update push#5694

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
SebTardif:fix/swallowed-checkout-error
May 19, 2026
Merged

🐛 (CLI): Fix redundant guard and swallowed checkout error in alpha update push#5694
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
SebTardif:fix/swallowed-checkout-error

Conversation

@SebTardif
Copy link
Copy Markdown
Contributor

What

Remove a redundant nested if opts.Push guard and check the git checkout error that was previously discarded with _ in the alpha update push path.

Why

Two issues in the push block of alpha update:

  1. The inner if opts.Push on line 209 is always true because the outer guard on line 208 already checks the same field. This is a copy-paste artifact.

  2. The git checkout error on line 211 is silently discarded with _. While the checkout is typically a no-op (the squash path already leaves the user on the output branch), silently discarding the error means any systemic git failure (corrupted state, locked index) is hidden from the user, who sees "Update completed successfully" despite the error.

The error check pattern matches the identical checkout handling at lines 197-198 for the ShowCommits path.

How

  • Removed the redundant inner if opts.Push block
  • Changed _ = helpers.GitCmd(...) to if err := helpers.GitCmd(...); err != nil { return ... }
  • Added integration tests for the push path (success and checkout failure error propagation)

Introduced in #5013 (2025-08-18).

…pha update push

Remove a redundant nested if opts.Push guard and check the git checkout
error that was previously discarded with _ in the alpha update push path.

The inner if opts.Push on line 209 is always true because the outer guard
on line 208 already checks the same field. This is a copy-paste artifact.

The git checkout error on line 211 is silently discarded with _. While the
checkout is typically a no-op (the squash path already leaves the user on
the output branch), silently discarding the error means any systemic git
failure (corrupted state, locked index) is hidden from the user, who sees
Update completed successfully despite the error.

The error check pattern matches the identical checkout handling at
lines 197-198 for the ShowCommits path.

Introduced in kubernetes-sigs#5013 (2025-08-18).

Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 13, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @SebTardif. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 13, 2026
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 13, 2026

// Push the output branch if requested
if opts.Push {
if opts.Push {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The command can work locally and not necessary we want to push the new branch
Therefore, we must to keep the option here

/hold

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! Just to clarify: the outer if opts.Push guard on line 208 is preserved, so the push remains fully optional. The only change is removing the duplicate inner if opts.Push that was nested inside it (always true, since the outer block already gates on the same condition), and surfacing the checkout error that was silently discarded with _.

The push behavior is unchanged: when Push is false, none of this code runs.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 15, 2026
@SebTardif
Copy link
Copy Markdown
Contributor Author

@camilamacedo86 The if opts.Push guard is preserved. The change only removes the redundant inner duplicate (the original code had if opts.Push { if opts.Push {) and checks the checkout error instead of discarding it with _ =.

The checkout still only runs inside if opts.Push, so local usage without push is unaffected.

@camilamacedo86
Copy link
Copy Markdown
Member

I see good catcher !!!
Thank you 🎉

@camilamacedo86
Copy link
Copy Markdown
Member

/hold cancel

/approved

/lgtm

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 15, 2026
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, SebTardif

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 15, 2026
@camilamacedo86 camilamacedo86 requested a review from Copilot May 15, 2026 09:11
@camilamacedo86
Copy link
Copy Markdown
Member

/override pull-kubebuilder-e2e-k8s-1-36-0

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-36-0

Details

In response to this:

/override pull-kubebuilder-e2e-k8s-1-36-0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@camilamacedo86
Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 15, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the reliability of the kubebuilder alpha update push flow by removing a redundant opts.Push guard and ensuring git checkout failures are surfaced to the user instead of being silently ignored.

Changes:

  • Removed a redundant nested if opts.Push block in the push path.
  • Propagated git checkout <output-branch> errors before attempting git push.
  • Added integration tests covering successful push behavior and checkout-failure error propagation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/cli/alpha/internal/update/update.go Removes redundant guard and returns a user-visible error when output-branch checkout fails before pushing.
internal/cli/alpha/internal/update/update_test.go Adds integration coverage for the push path (success case and checkout failure propagation).

@SebTardif
Copy link
Copy Markdown
Contributor Author

/retest-required

@camilamacedo86
Copy link
Copy Markdown
Member

/override pull-kubebuilder-e2e-k8s-1-36-0

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-36-0

Details

In response to this:

/override pull-kubebuilder-e2e-k8s-1-36-0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@camilamacedo86
Copy link
Copy Markdown
Member

/override pull-kubebuilder-e2e-k8s-1-36-0

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@camilamacedo86: Overrode contexts on behalf of camilamacedo86: pull-kubebuilder-e2e-k8s-1-36-0

Details

In response to this:

/override pull-kubebuilder-e2e-k8s-1-36-0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot merged commit e160d2b into kubernetes-sigs:master May 19, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants