diff --git a/.github/scripts/check_labels.py b/.github/scripts/check_labels.py index 10be42c3fd5..0075050155e 100644 --- a/.github/scripts/check_labels.py +++ b/.github/scripts/check_labels.py @@ -45,15 +45,15 @@ def main() -> None: try: if not has_required_labels(pr): - print(LABEL_ERR_MSG) + print(LABEL_ERR_MSG, flush=True) add_label_err_comment(pr) if args.exit_non_zero: - sys.exit(1) + raise RuntimeError("PR does not have required labels") else: delete_all_label_err_comments(pr) except Exception as e: if args.exit_non_zero: - sys.exit(1) + raise RuntimeError(f"Error checking labels: {e}") from e sys.exit(0) diff --git a/.github/scripts/github_utils.py b/.github/scripts/github_utils.py index 1650b93df52..1583639b1f9 100644 --- a/.github/scripts/github_utils.py +++ b/.github/scripts/github_utils.py @@ -72,10 +72,10 @@ def gh_fetch_url( headers: Optional[Dict[str, str]] = None, data: Union[Optional[Dict[str, Any]], str] = None, method: Optional[str] = None, - reader: Callable[[Any], Any] = lambda x: x.read(), + reader: Callable[[Any], Any] = json.load, ) -> Any: return gh_fetch_url_and_headers( - url, headers=headers, data=data, reader=json.load, method=method + url, headers=headers, data=data, reader=reader, method=method )[1] @@ -169,7 +169,7 @@ def gh_post_commit_comment( def gh_delete_comment(org: str, repo: str, comment_id: int) -> None: url = f"{GITHUB_API_URL}/repos/{org}/{repo}/issues/comments/{comment_id}" - gh_fetch_url(url, method="DELETE") + gh_fetch_url(url, method="DELETE", reader=lambda x: x.read()) def gh_fetch_merge_base(org: str, repo: str, base: str, head: str) -> str: