Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Handle GitHub errors #412

Closed
wants to merge 23 commits into from
Closed

Handle GitHub errors #412

wants to merge 23 commits into from

Conversation

jhaff
Copy link
Contributor

@jhaff jhaff commented Nov 6, 2019

Moved to #431


Description

Fixes #409

This PR consolidates error handling logic for the case when a user's account is suspended(Octokit::AccountSuspended) and when a user's account is missing from Github (GithubPullRequestService::UserNotFoundOnGithubError). This sits in a new service object which gets passed a user and a block, GithubErrorHandler.

For both of these errors, we handle by deactivating the user, putting them in the inactive state (a new state on the state machine specifically for these users no longer accounted for in GitHub) and deleting their associated UserStat, if they have one.

Test process

  • Test that a user causing this error gets deactivated and out in the inactive state
  • Test that that user's UserStat is deleted, if they had one
  • Test that if an unhandled error is passed to the GithubErrorHandler, it raises the error

Requirements to merge

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@jhaff jhaff force-pushed the handle-github-errors branch 2 times, most recently from 40e4c0c to b5c04e0 Compare November 8, 2019 16:57
@jhaff
Copy link
Contributor Author

jhaff commented Nov 8, 2019

Rebased and added tests, ready for eyes

Tests passing locally:
image

@jhaff jhaff changed the title WIP: Handle GitHub errors Handle GitHub errors Nov 8, 2019
@jhaff jhaff marked this pull request as ready for review November 8, 2019 16:59
Copy link
Contributor

@johndbritton johndbritton left a comment

Choose a reason for hiding this comment

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

Looking good. Need @mkcode to approve.

Also, update the PR body description.

app/services/github_error_handler.rb Outdated Show resolved Hide resolved
@johndbritton
Copy link
Contributor

It might be worth storing the state the user went inactive from when we transition them.

Copy link
Contributor

@mkcode mkcode left a comment

Choose a reason for hiding this comment

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

Also - we need to add the handler to the most important case - the UserTransitionJob

@mkcode
Copy link
Contributor

mkcode commented Nov 11, 2019

Ok. Let's address @johndbritton's concern as well. Let's add a state_before_inactive column which logs the previous state in the same context as when we set the last_error

@jhaff jhaff requested a review from mkcode November 11, 2019 20:38
@jhaff
Copy link
Contributor Author

jhaff commented Nov 11, 2019

Force push for rebase

Copy link
Contributor

@mkcode mkcode left a comment

Choose a reason for hiding this comment

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

Still missed adding this error handling to the TryUserTransitionJob

app/models/user.rb Outdated Show resolved Hide resolved
app/models/user.rb Show resolved Hide resolved
@jhaff jhaff requested a review from mkcode November 11, 2019 22:39
app/models/user.rb Show resolved Hide resolved
app/services/github_pull_request_service.rb Show resolved Hide resolved
spec/models/user_spec.rb Show resolved Hide resolved
spec/models/user_spec.rb Show resolved Hide resolved
spec/models/user_spec.rb Show resolved Hide resolved
@jhaff
Copy link
Contributor Author

jhaff commented Nov 12, 2019

****PR moved to #431

@johndbritton johndbritton deleted the handle-github-errors branch November 12, 2019 23:10
@jhaff jhaff mentioned this pull request Nov 12, 2019
9 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle Github Errors Appropriately
3 participants