Skip to content

Add REST API fallback for PR files collection #3138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Xiaoha-cloud
Copy link

Description

  • This PR implements a fallback mechanism to collect pull request files using GitHub's REST API when the GraphQL query fails. The changes address the issue where some PR files are not accessible via GraphQL but can be retrieved through the REST API.

This PR fixes #2875

Notes for Reviewers

  1. augur/tasks/github/pull_requests/files_model/core.py

    • Added REST API fallback mechanism when GraphQL returns None
    • Implemented error handling for cases where PR doesn't exist
    • Added logging for better debugging
    • Modified the file collection logic to try REST API when GraphQL fails
    • This directly addresses the issue by providing an alternative data collection method
  2. augur/tasks/github/util/github_api_errors.py (New)

    • Added base exception class GitHubAPIError for GitHub API errors
    • Added RateLimitError for handling rate limit issues
    • Added AuthenticationError for authentication failures
    • This provides a consistent error handling structure across the codebase
  3. augur/tasks/github/util/github_graphql_data_access.py (Modified)

    • Enhanced error handling for GraphQL API requests
    • Improved handling of None responses
    • Added better logging for API failures
    • This ensures robust GraphQL communication and error recovery
  4. augur/tasks/github/util/retry.py (New)

    • Added error handling classes for API failures
    • Implemented retry mechanism with exponential backoff
    • Added rate limit handling
    • This file is necessary to handle API failures gracefully and ensure reliable data collection

Implementation Details

  • When GraphQL returns None (as in the example with PR Pipermail SQL Date Column #121 in Picovoice/porcupine), the system now automatically falls back to the REST API
  • For non-existent PRs (like PR Calculating the Truck-Factor of git Applications #27 in automatic1111/stable-diffusion-webui), the system handles the error gracefully
  • The implementation maintains backward compatibility while adding the new fallback mechanism
  • Error handling is now more robust with dedicated exception classes
  • Rate limiting is handled more gracefully with proper retry mechanisms

Signed commits

  • Yes, I signed my commits.

@Xiaoha-cloud Xiaoha-cloud requested a review from sgoggins as a code owner April 29, 2025 15:09
@Xiaoha-cloud Xiaoha-cloud changed the base branch from main to dev April 29, 2025 15:10
@Xiaoha-cloud Xiaoha-cloud force-pushed the pr-files-rest-fallback branch from 649c4c0 to 09aa594 Compare April 29, 2025 15:23
)

Signed-off-by: Xiaoha <blairjade183@gmail.com>
@Xiaoha-cloud Xiaoha-cloud force-pushed the pr-files-rest-fallback branch from 09aa594 to 586895c Compare April 29, 2025 15:41
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.

Collect Pull Request Files from Rest API when GraphQL Query Fails
1 participant