Gracefully handle deleted GitHub users in user_name_by_id#574
Open
VasilevNStas wants to merge 1 commit into
Open
Gracefully handle deleted GitHub users in user_name_by_id#574VasilevNStas wants to merge 1 commit into
VasilevNStas wants to merge 1 commit into
Conversation
Contributor
Author
|
@yegor256 plz review |
When a GitHub user is deleted, the API returns 403 (Octokit::Forbidden) instead of 404, because the user ID is known but access is restricted. Previously this caused an unhandled runtime exception in the add-user-names judge and crashed the pipeline. Now both Octokit::NotFound and Octokit::Forbidden are rescued, a warning is logged, and nil is returned. Callers can handle missing users gracefully.
a0af59c to
891696c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When a GitHub user is deleted, the API returns
403 Forbiddeninstead of404, because the user ID is known but access is restricted. Theuser_name_by_idmethod inlib/fbe/octo.rbdid not handle this exception, causing the pipeline to crash in theadd-user-namesjudge (see zerocracy/pages-action#131).Now both
Octokit::NotFoundandOctokit::Forbiddenare rescued inuser_name_by_id. On these errors, the method logs a warning and returnsnil, allowing callers to gracefully handle missing users.Changes
lib/fbe/octo.rb— rescueOctokit::NotFoundandOctokit::Forbiddeninuser_name_by_idtest/fbe/test_octo.rb— addtest_user_name_by_id_returns_nil_on_forbiddenCloses zerocracy/pages-action#131