Skip to content

improvement(util): wrap Retry last error with %w for error chain pres…#381

Open
mdryaan wants to merge 1 commit into
kubeslice:masterfrom
mdryaan:improvement/retry-error-wrapping
Open

improvement(util): wrap Retry last error with %w for error chain pres…#381
mdryaan wants to merge 1 commit into
kubeslice:masterfrom
mdryaan:improvement/retry-error-wrapping

Conversation

@mdryaan

@mdryaan mdryaan commented May 17, 2026

Copy link
Copy Markdown

Description

util.Retry in util/common.go (line 220) used %s as the verb when wrapping the last error in the final fmt.Errorf call. This converts the error to a plain string, permanently discarding its type. Any caller using errors.Is or errors.As on a util.Retry return value would always get false, making it impossible to inspect or match the underlying cause. Changing %s to %w makes the error chain available to callers without any behaviour change at runtime.

Fixes #380

How Has This Been Tested?

util/common.go line 220 changed from %s to %w. go build ./... passes. The pre-existing make vet and make unit-test failures (undefined: util.Client, unknown field ClusterName) exist on master before this branch and are unrelated to this change.

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates? — No.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit test cases.

…ervation

Signed-off-by: mdryaan <alikhurshid4u@gmail.com>
@mdryaan mdryaan requested a review from that-backend-guy as a code owner May 17, 2026 13:48
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.

Improvement: util.Retry uses %s instead of %w, discarding the error chain

1 participant