The Wayback Machine - https://web.archive.org/web/20200930085938/https://github.com/forem/forem/issues/10106
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

Refactor: improve error handling in GithubRepos::RepoSyncWorker #10106

Open
rhymes opened this issue Aug 31, 2020 · 2 comments
Open

Refactor: improve error handling in GithubRepos::RepoSyncWorker #10106

rhymes opened this issue Aug 31, 2020 · 2 comments

Comments

@rhymes
Copy link
Contributor

@rhymes rhymes commented Aug 31, 2020

Currently we're inspecting the error message to determine if a user's account was suspended or if the repository has become unavailable so that we can destroy it

rescue Github::Errors::ClientError => e
msg = e.message
raise e unless msg.include?("Your account was suspended") || msg.include?("Repository access blocked")
repo.destroy
end

Ockokit (the GitHub library we use) has two specific errors for those two cases: Octokit::RepositoryUnavailable and Octokit::AccountSuspended.

It'd be nice to replace those messages inspection with the correct error classes.

See https://github.com/octokit/octokit.rb/blob/a69f5eab0a2fb2763fcda9fadcb0c961df96a373/lib/octokit/error.rb#L265 and https://github.com/octokit/octokit.rb/blob/a69f5eab0a2fb2763fcda9fadcb0c961df96a373/lib/octokit/error.rb#L257

By adding two exceptions similarly named, RepositoryUnavailable and AccountSuspended, to https://github.com/forem/forem/blob/master/app/services/github/errors.rb one should be able to handle them correctly in the worker, without inspecting the message and thus keeping the same behaviour

Originally posted by @rhymes in #10103 (comment)

@github-actions
Copy link

@github-actions github-actions bot commented Aug 31, 2020

Thanks for the issue! We'll take your request into consideration and follow up if we decide to tackle this issue.

To our amazing contributors: issues labeled type: bug are always up for grabs, but for feature requests, please wait until we add a ready for dev before starting to work on it.

To claim an issue to work on, please leave a comment. If you've claimed the issue and need help, please ping @forem/oss and we will follow up within 3 business days.

For full info on how to contribute, please check out our contributors guide.

@diogoosorio
Copy link
Contributor

@diogoosorio diogoosorio commented Sep 1, 2020

FYI I'll give this one a crack. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.