Skip to content

Fix for Wrapped error is always nil#538

Merged
alexeykiselev merged 1 commit intomainfrom
finding-autofix-8c93b365
Apr 2, 2026
Merged

Fix for Wrapped error is always nil#538
alexeykiselev merged 1 commit intomainfrom
finding-autofix-8c93b365

Conversation

@nickeskov
Copy link
Copy Markdown
Collaborator

In general, to fix this problem you should avoid calling errors.Wrap (or similar) with an error value that is known to be nil. Instead, either return a newly constructed error that describes the situation, or ensure you are wrapping a real underlying error. In this specific case, on the branch where resp.StatusCode == http.StatusInternalServerError, there is no underlying err—the HTTP request succeeded but returned a 500 status. The best fix is to replace errors.Wrap(err, "failed to remove webhook") with a new descriptive error that explains the non-OK HTTP status, for example using errors.Errorf and including resp.Status or resp.StatusCode. This preserves existing behavior (still returns an error in that condition) while removing the meaningless wrap.

Concretely, in cmd/bots/internal/telegram/config/config.go, modify the block starting at line 84 so that instead of return errors.Wrap(err, "failed to remove webhook") it returns a newly formatted error like errors.Errorf("failed to remove webhook: %s", resp.Status) or similar. No new imports or helpers are needed; github.com/pkg/errors is already imported and provides Errorf. The rest of the function, including the deferred body-close logic and other errors.Wrap calls where err is genuinely non-nil, should remain unchanged.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@nickeskov nickeskov marked this pull request as ready for review April 2, 2026 14:28
@nickeskov nickeskov requested a review from alexeykiselev April 2, 2026 14:28
@alexeykiselev alexeykiselev merged commit 9e95de4 into main Apr 2, 2026
14 checks passed
@alexeykiselev alexeykiselev deleted the finding-autofix-8c93b365 branch April 2, 2026 17:37
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.

2 participants