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

shared_audits: ensure GitLab API response is valid #8625

Merged
merged 1 commit into from
Sep 5, 2020

Conversation

dtrodrigues
Copy link
Member

  • 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 tests with your changes locally?

The GitLab API returns an HTTP 403 and a body of
{"message":"403 Forbidden"}
if a release doesn't exist, eg https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-runner/releases/does-not-exist. This causes the current audit logic to fail when trying to get release_date. The change will ensure there's a release_date in the response before continuing.

For a more robust solution, the HTTP response code should be considered for GitLab API calls prior to working with the data.

Resolves audit exception in Homebrew/homebrew-core#60669

Sorry, something went wrong.

@reitermarkus
Copy link
Member

reitermarkus commented Sep 5, 2020

If the API still returns a JSON body on error why does parse fail?

@reitermarkus
Copy link
Member

Maybe pass --fail to curl_output rather than checking the output?

@reitermarkus
Copy link
Member

Also the--request GET can be removed since that's the default.

@dtrodrigues
Copy link
Member Author

Date.parse(release["released_at"]) threw an exception because release["released_at"] was nil and Date.parse takes in a string.

I did change to use the --fail flag instead for the curl call.

@dtrodrigues dtrodrigues changed the title shared_audits: ensure GitLab API response has release date shared_audits: ensure GitLab API response is valid Sep 5, 2020
@reitermarkus
Copy link
Member

Date.parse(release["released_at"]) threw an exception

Ah, I thought it was JSON.parse.

@dtrodrigues dtrodrigues merged commit 33de853 into Homebrew:master Sep 5, 2020
@dtrodrigues dtrodrigues deleted the gitlab-release branch September 5, 2020 18:54
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 13, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 13, 2020
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