Fix: Handle bot users gracefully when metadata is unavailable#920
Open
isidromontero wants to merge 3 commits intojenkinsci:masterfrom
Open
Fix: Handle bot users gracefully when metadata is unavailable#920isidromontero wants to merge 3 commits intojenkinsci:masterfrom
isidromontero wants to merge 3 commits intojenkinsci:masterfrom
Conversation
Repository scans were failing with FileNotFoundException when PRs were authored by bot users (e.g., GitHub Copilot) whose metadata is not accessible via the GitHub API. Problem: - Scan aborts with FATAL error when user metadata fetch returns 404 - This prevents orphanedItemStrategy from executing - Results in accumulation of orphaned PR branches Solution: - Implement tolerant error handling for user metadata fetching - Use default values (login, login@users.noreply.github.com) when metadata is unavailable - Log warnings instead of throwing exceptions - Allow scan to complete successfully This ensures bot-authored PRs don't block repository indexing and orphaned item cleanup can proceed as configured. Fixes scan failures with bot users like GitHub Copilot. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The fix for handling bot users whose metadata is unavailable changed the behavior from throwing exceptions to gracefully processing PRs with default values. Updated tests to reflect this new, correct behavior: - fetchSmokes_badUser: PR-2 is now included in results with default values - testOpenSinglePRThrowsFileNotFoundOnObserve: Successfully processes PR instead of throwing - testOpenSinglePRThrowsIOOnObserve: Successfully processes PR instead of throwing This ensures PRs from bots (like GitHub Copilot) are processed instead of causing repository scan failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
This is also impacting us. It leads to not triggering builds because we rely on the branch indexing. |
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.
Problem Description
Repository scans fail completely with a FATAL error when a Pull Request is authored by a bot user (such as GitHub Copilot) whose user metadata is not accessible via the GitHub API.
Error Details
When scanning a repository with PRs from bot users, the scan aborts with:
Impact
Root Cause
In
GitHubSCMSource.java, theCacheUpdatingIterable.observe()method (line 2596) throws aWrappedExceptionwhen user metadata cannot be fetched:This behavior is problematic because:
/users/Copilotendpoint (returns 404)Changes Made
This PR implements tolerant error handling that uses default values when user metadata is unavailable:
Key Changes
Graceful degradation for user metadata:
user.getName()anduser.getEmail()FileNotFoundException(404), use default values: login as name,login@users.noreply.github.comas emailRemove unnecessary try-catch:
getTitle(),getBody(),getHtmlUrl()) which don't throw checked exceptionsMaintain backward compatibility:
Code Example
Benefits
Testing
Tested locally by:
Checklist
mvn clean package -DskipTests)Note: This fix addresses a critical production issue where bot-authored PRs prevent repository indexing and orphaned item cleanup, leading to significant disk space consumption.