Skip to content

Use %w for error wrapping in controller.cancelDeployment#6936

Open
mvanhorn wants to merge 1 commit into
pipe-cd:masterfrom
mvanhorn:fix/6932-2026-06-24-167-bugfix-cancel-deployment-error-wrap
Open

Use %w for error wrapping in controller.cancelDeployment#6936
mvanhorn wants to merge 1 commit into
pipe-cd:masterfrom
mvanhorn:fix/6932-2026-06-24-167-bugfix-cancel-deployment-error-wrap

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

cancelDeployment now wraps the error returned by ReportDeploymentCompleted with %w instead of %v, so callers can use errors.Is/errors.As to inspect the underlying cause.

Why this matters

The cancellation path formatted the reporting error with %v, which flattens it to a string and breaks error-chain inspection for any caller that wants to branch on the wrapped error. Switching to %w preserves the chain while keeping the existing message format. Reported in #6932.

Testing

Added a regression test that drives cancelDeployment with a fake API client returning a sentinel error and asserts errors.Is matches the wrapped error, so the test fails if the wrapping regresses to %v. The controller package tests pass.

Closes #6932

Signed-off-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
@mvanhorn mvanhorn requested a review from a team as a code owner June 24, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: for error wrapping in cancelDeployment

1 participant