Skip to content

Gracefully handle deleted GitHub users in user_name_by_id#574

Open
VasilevNStas wants to merge 1 commit into
zerocracy:masterfrom
VasilevNStas:131-user-name-by-id-forbidden
Open

Gracefully handle deleted GitHub users in user_name_by_id#574
VasilevNStas wants to merge 1 commit into
zerocracy:masterfrom
VasilevNStas:131-user-name-by-id-forbidden

Conversation

@VasilevNStas

@VasilevNStas VasilevNStas commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

When a GitHub user is deleted, the API returns 403 Forbidden instead of 404, because the user ID is known but access is restricted. The user_name_by_id method in lib/fbe/octo.rb did not handle this exception, causing the pipeline to crash in the add-user-names judge (see zerocracy/pages-action#131).

Now both Octokit::NotFound and Octokit::Forbidden are rescued in user_name_by_id. On these errors, the method logs a warning and returns nil, allowing callers to gracefully handle missing users.

Changes

  • lib/fbe/octo.rb — rescue Octokit::NotFound and Octokit::Forbidden in user_name_by_id
  • test/fbe/test_octo.rb — add test_user_name_by_id_returns_nil_on_forbidden

Closes zerocracy/pages-action#131

@VasilevNStas VasilevNStas changed the title #131: Gracefully handle deleted GitHub users in user_name_by_id Gracefully handle deleted GitHub users in user_name_by_id Jun 30, 2026
@VasilevNStas

Copy link
Copy Markdown
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User not found leads to runtime exception

1 participant