Update handling of commit data requests to account for API failure #317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the pull request
This improves handling and logging of failures while processing pull requests if the checks or checksuite API fails from Octokit. The intent here is to allow pull requests to continue to process even if we cannot obtain their checks information, and to clean up any data they may have so we do not get state tear or data corruption.
References and relevant issues
Closes #316
Detailed description of the pull request / Additional comments
We started seeing some errors coming from a small set of pull requests originating in Octokit. These errors were related to the Checks data requests. These are new and did not occur previously and appear to be tied to specific pull requests, but not all pull requests.
For most data we process by querying a repository once and then processing each item in the result. In the case of pull requests, we query the data multiple times for Checks information for each pull request. If one of the checks information fails it can cause the entire data sync to fail. @guimafelipe put in a quick fix for this for failures observed in the Pull Requests widget, but they were also occurring in the developer pull requests (used for notifications).
This fix addresses that problem more thoroughly. In addition to handling both types of checks API calls, the data deletion was also moved up in the code to happen first, before we attempt to query the new data. This ensures we have removed all existing data before we hit an exception in querying the new data, which keeps the data in a good state. The logging was also tweaked so we keep error messages short and not dump the entire stack (which can be very large in the case of Octokit failures). Instead we will log the error and then put the detailed stack in the Debug output.
Specific changes:
Also added a user loginid of the GitHub client logging of the Repository query. This is unrelated to this change but in the area and useful now that we support multiple GitHub accounts so it is clear which login is being used to make the query for troubleshooting.
Validation steps performed
PR checklist