Skip to content
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

Curl: Remove guard from certain parsing logic #13195

Conversation

samford
Copy link
Member

@samford samford commented Apr 26, 2022

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

@bevanjkay brought it to my attention that some cask PRs started failing on CI with a The binary url ... is not reachable error after #11252 was merged. This error message comes from the Utils::Curl#curl_check_http_content method, which calls #curl_http_content_headers_and_checksum. Both of these methods were modified in that PR but the issue arises from the latter.

Long story short, I naively moved the response parsing logic in #curl_http_content_headers_and_checksum into the if status.success? block and this change causes this error to arise when the download for a URL doesn't finish before the 25 second timeout. Previously, this method would parse the output regardless of whether a final response arrived and this would technically work if there were other responses in the output (e.g., redirections).

This PR reinstates the previous behavior by moving the parsing logic back out of the if status.success? block, which resolves this issue. We may want to look into this further after this is merged but I wanted to get this fix out relatively quickly, to unblock related cask PRs.

I was able to replicate this issue locally (and confirm the fix) using the visual-paradigm cask (related open PR: Homebrew/homebrew-cask#122490) because the dmg file is ~750 MB and this will trigger the curl timeout. You can test this locally using brew audit --cask --appcast --online visual-paradigm.

I've labelled this as "critical", since it's a bug fix. I did a limited amount of testing and didn't see any new errors but if anyone wants to test this more before merging, please feel free. It's very late over here and I'm crawling into bed but I can check on this again in the morning (EDT).

The `#curl_http_content_headers_and_checksum` method previously
parsed responses from `curl` output even if `status.success?` wasn't
`true`. A recent commit of mine moved the parsing logic behind this
guard but it's now leading to a "...is not reachable" error when a URL
involves a large download that takes longer than 25 seconds to finish
and hits the timeout.

This commit resolves the issue for the time being by moving related
logic back to its previous location, where it isn't guarded by
`status.success?`.
@samford samford added the critical Critical change which should be shipped as soon as possible. label Apr 26, 2022
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

@bevanjkay
Copy link
Member

Thanks @samford. I appreciate you getting to this as quickly as you have!

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Thanks @samford for the quick turnaround!

@MikeMcQuaid MikeMcQuaid merged commit 048f849 into Homebrew:master Apr 26, 2022
@samford samford deleted the curl_http_content_headers_and_checksum-reinstate-old-return-behavior branch April 26, 2022 13:21
@github-actions github-actions bot added the outdated PR was locked due to age label May 27, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants