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

Strategy: Improve curl error message finding #11973

Conversation

samford
Copy link
Member

@samford samford commented Sep 4, 2021

  • 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?

When I originally migrated livecheck to curl, the errors we were encountering typically started with curl: and a number in parentheses before the error message (e.g., curl: (60) SSL certificate problem: certificate has expired). However, curl produces some errors that don't adhere to this format.

In some cases, the error message doesn't include a leading number in parentheses. Additionally, some errors can include multiple messages. For example:

curl: option --something: is unknown
curl: try 'curl --help' or 'curl --manual' for more information

With this in mind, it's necessary to loosen the regex that's used to identify curl error messages and to use #scan to collect all of the error message lines in stderr. Otherwise we incorrectly miss certain error messages and get the fallback cURL failed without an error message, which we shouldn't see.


For what it's worth, I encountered this shortcoming as part of implementing support for specifying curl args in a livecheck block. I'll be creating a PR for that work soon but I wanted to extract this commit from that branch beforehand, to simplify the forthcoming PR.

@BrewTestBot
Copy link
Member

Review period will end on 2021-09-07 at 00:00:00 UTC.

@BrewTestBot BrewTestBot added waiting for feedback Merging is blocked until sufficient time has passed for review and removed waiting for feedback Merging is blocked until sufficient time has passed for review labels Sep 4, 2021
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.

Makes sense! One wording tweak to avoid this happening again if the format doesn't align again in future.

Library/Homebrew/livecheck/strategy.rb Outdated Show resolved Hide resolved
@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Sep 7, 2021
@BrewTestBot
Copy link
Member

Review period ended.

The existing regex wasn't able to match errors like:
  curl: option --something: is unknown

Additionally, the existing approach wouldn't capture multi-line
errors, whereas this captures all the `curl:` lines from `stderr`.
@samford samford force-pushed the livecheck/improve-curl-error-message-handling branch from 28cfb44 to 6b66ec9 Compare September 7, 2021 04:15
@samford samford merged commit 84f4fbf into Homebrew:master Sep 7, 2021
@samford samford deleted the livecheck/improve-curl-error-message-handling branch September 7, 2021 04:36
@github-actions github-actions bot added the outdated PR was locked due to age label Oct 8, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants