Skip to content

Collect Pull Request Files from Rest API when GraphQL Query Fails #2875

Open
@sgoggins

Description

@sgoggins

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}}}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions