augur icon indicating copy to clipboard operation
augur copied to clipboard

Collect Pull Request Files from Rest API when GraphQL Query Fails

Open sgoggins opened this issue 1 year ago • 2 comments

Example: This PR's files do not return in graphql, but we can get them in the REST API: https://api.github.com/repos/Picovoice/porcupine/pulls/121/files?per_page=100

However, there are other cases where the PR may not exist anymore (see commit hacks that break github): https://api.github.com/repos/automatic1111/stable-diffusion-webui/pulls/27/files?per_page=100

The GraphQL Error for this one is:

Traceback (most recent call last):
  File "/home/ubuntu/github/virtualenvs/hosted/lib/python3.11/site-packages/celery/app/trace.py", line 451, in trace_task
    R = retval = fun(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/github/virtualenvs/hosted/lib/python3.11/site-packages/celery/app/trace.py", line 734, in __protected_call__
    return self.run(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/github/augur/augur/tasks/github/pull_requests/files_model/tasks.py", line 18, in process_pull_request_files
    pull_request_files_model(repo.repo_id, logger, augur_db, manifest.key_auth, full_collection)
  File "/home/ubuntu/github/augur/augur/tasks/github/pull_requests/files_model/core.py", line 78, in pull_request_files_model
    for pr_file in github_graphql_data_access.paginate_resource(query, params, values):
  File "/home/ubuntu/github/augur/augur/tasks/github/util/github_graphql_data_access.py", line 48, in paginate_resource
    raise Exception(f"Error: data section of response is None. Variables: {variables}. Query: {query}. Response: {result_json}")
Exception: Error: data section of response is None. Variables: {'owner': 'automatic1111', 'repo': 'stable-diffusion-webui', 'pr_number': 27}. Query: 
            query($repo: String!, $owner: String!,$pr_number: Int!, $numRecords: Int!, $cursor: String) {
                repository(name: $repo, owner: $owner) {
                    pullRequest(number: $pr_number) {
                        files ( first: $numRecords, after: $cursor) {
                            edges {
                                node {
                                    additions
                                    deletions
                                    path
                                }
                            }
                            totalCount
                            pageInfo {
                                hasNextPage
                                endCursor
                            }
                        }
                    }
                }
            }
        . Response: {'data': {'repository': {'pullRequest': {'files': None}}}}

sgoggins avatar Jul 23 '24 01:07 sgoggins

Hi, I am interested in joining Google Summer of Code this year, I am a sophomore Bucknell computer science student. I am familiar with this framework, can you introduce me more about this issues. I also really want to try on this problem, can you assign it to me?

DuyLe0710edu avatar Apr 02 '25 22:04 DuyLe0710edu

Hi, I'd like to take on this issue as my contribution to CHAOSS Augur! I have experience working with REST and GraphQL APIs and would love to help implement a fallback mechanism from GraphQL to REST in this case.

Please let me know if I can proceed with a PR. 😊

xiaoha-cloud avatar Apr 20 '25 14:04 xiaoha-cloud