diff --git a/tests/ci/pr_info.py b/tests/ci/pr_info.py index 0de4ec89124..be15b0817bf 100644 --- a/tests/ci/pr_info.py +++ b/tests/ci/pr_info.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import json +import logging import os from unidiff import PatchSet # type: ignore @@ -98,12 +99,20 @@ class PRInfo: if "pull_request" in github_event: # pull request and other similar events self.number = github_event["pull_request"]["number"] if pr_event_from_api: - response = get_with_retries( - f"https://api.github.com/repos/{GITHUB_REPOSITORY}" - f"/pulls/{self.number}", - sleep=RETRY_SLEEP, - ) - github_event["pull_request"] = response.json() + try: + response = get_with_retries( + f"https://api.github.com/repos/{GITHUB_REPOSITORY}" + f"/pulls/{self.number}", + sleep=RETRY_SLEEP, + ) + github_event["pull_request"] = response.json() + except Exception as e: + logging.warning( + "Unable to get pull request event %s from API, " + "fallback to received event. Exception: %s", + self.number, + e, + ) if "after" in github_event: self.sha = github_event["after"]