Skip to content

dev: improve HTTP download error handling for wget and curl #5962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tjasko
Copy link

@tjasko tjasko commented Jul 28, 2025

Summary

This PR improves the error handling and consistency between http_download_curl and http_download_wget in install.sh.

Changes

  • Updated http_download_curl to use log_err for non-200 HTTP status codes instead of log_debug.
  • Enhanced http_download_wget to:
    • Capture and evaluate the HTTP status code using wget --server-response.
      • Return an exit status of 1 for non-200 HTTP responses, matching the behavior of http_download_curl.
      • Log errors via log_err for better visibility.
    • Simplified http_download to directly call http_download_wget after its availability check.

Why

Previously, http_download_wget did not validate HTTP response codes, which led to misleading behavior. For example, when GitHub returned an HTTP 503, the installer incorrectly reported that the requested version did not exist:

$ ./install.sh v1.64.8
golangci/golangci-lint info checking GitHub for tag 'v1.64.8'
golangci/golangci-lint crit unable to find 'v1.64.8' - use 'latest' or see https://github.com/golangci/golangci-lint/releases for details

In this case, the tag v1.64.8 did exist, but the underlying issue was a GitHub service error returning a 503. By properly checking and logging HTTP response codes, this update makes such scenarios clearer to users and avoids misleading "version not found" messages.

@CLAassistant
Copy link

CLAassistant commented Jul 28, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

boring-cyborg bot commented Jul 28, 2025

Hey, thank you for opening your first Pull Request !

- Updated `http_download_curl` to log HTTP errors using `log_err` instead of `log_debug`.
- Modified `http_download_wget` to check HTTP status codes, mirroring curl's behavior.
- Return exit status 1 for non-200 responses in `http_download_wget`.
- Standardized error logging across both download functions.
@tjasko tjasko force-pushed the fix/install-script-check-http-status branch from 6b3e0fa to cdf68aa Compare July 28, 2025 23:08
@ldez ldez added the area: install Issue relates to installation or downloading process label Jul 28, 2025
@ldez ldez self-requested a review July 28, 2025 23:09
@ldez ldez changed the title fix: improve HTTP download error handling for wget and curl dev: improve HTTP download error handling for wget and curl Jul 28, 2025
Comment on lines +318 to +320
if [ "$code" != "200" ]; then
log_err "http_download_wget received HTTP status $code"
return 1
Copy link
Member

Choose a reason for hiding this comment

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

this doesn't work in all cases, and it can hide other errors.

$ wget --server-response --quiet -O foo http://example.g 2>&1 | awk '/^  HTTP/{print $2}' | tail -n1
$ echo $?
0
$ wget --server-response --quiet -O foo http://example.g
$ echo $?
4
$ wget --server-response -O foo http://example.g
--2025-07-28 23:19:59--  http://example.g/
Resolving example.g (example.g)... failed: Name or service not known.
wget: unable to resolve host address 'example.g'

Copy link
Author

Choose a reason for hiding this comment

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

Ah, good catch. Will look into it soon enough. Thanks for the quick review!

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in a8f43c2

@ldez ldez added the feedback required Requires additional feedback label Jul 28, 2025
@tjasko tjasko requested a review from ldez July 29, 2025 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: install Issue relates to installation or downloading process feedback required Requires additional feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants