Skip to content

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

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
sgoggins opened this issue Jul 23, 2024 · 2 comments · May be fixed by #3138
Open

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

sgoggins opened this issue Jul 23, 2024 · 2 comments · May be fixed by #3138

Comments

@sgoggins
Copy link
Member

sgoggins commented Jul 23, 2024

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 sgoggins converted this from a draft issue Jul 23, 2024
@ABrain7710 ABrain7710 moved this from In Progress to Backlog in Augur TSC Jul 23, 2024
@DuyLe0710edu
Copy link

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?

@Xiaoha-cloud
Copy link

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 added a commit to Xiaoha-cloud/augur that referenced this issue Apr 29, 2025
) - Add REST API fallback mechanism - Improve error handling and logging - Optimize GraphQL query handling - Fix database session management - Enhance file data collection and processing
Xiaoha-cloud added a commit to Xiaoha-cloud/augur that referenced this issue Apr 29, 2025
) - Add REST API fallback mechanism - Improve error handling and logging - Optimize GraphQL query handling - Fix database session management - Enhance file data collection and processing

Signed-off-by: Xiaoha <blairjade183@gmail.com>
Xiaoha-cloud added a commit to Xiaoha-cloud/augur that referenced this issue Apr 29, 2025
)

Signed-off-by: Xiaoha <blairjade183@gmail.com>
@Xiaoha-cloud Xiaoha-cloud linked a pull request Apr 29, 2025 that will close this issue
1 task
Xiaoha-cloud added a commit to Xiaoha-cloud/augur that referenced this issue Apr 29, 2025
)

Signed-off-by: Xiaoha <blairjade183@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

3 participants