[Recipe cookbook] Addressing GitHub api format issue (#4424)

This commit is contained in:
Ebony Louis
2025-08-29 10:03:20 -04:00
committed by GitHub
parent 69c29a0870
commit 31cf6b8c37
+29 -2
View File
@@ -209,8 +209,35 @@ def main():
pr_data = fetch_pr_body(PR_URL, GITHUB_TOKEN)
pr_body = pr_data.get("body", "")
pr_number = pr_data["number"]
repo_full_name = pr_data["base"]["repo"]["full_name"]
# Handle cases where pr_data might be missing expected fields
pr_number = pr_data.get("number")
if not pr_number:
print("❌ Unable to get PR number from GitHub API response")
print(f"Available keys in response: {list(pr_data.keys())}")
# Try to extract number from URL if available
if "html_url" in pr_data:
import re
match = re.search(r'/pull/(\d+)', pr_data["html_url"])
if match:
pr_number = int(match.group(1))
print(f"✅ Extracted PR number from URL: {pr_number}")
else:
print("❌ Could not extract PR number from URL either")
exit(1)
else:
print("❌ No html_url available to extract PR number")
exit(1)
# Get repo info
if "base" in pr_data and "repo" in pr_data["base"]:
repo_full_name = pr_data["base"]["repo"]["full_name"]
elif "repository" in pr_data:
repo_full_name = pr_data["repository"]["full_name"]
else:
print("❌ Unable to get repository name from GitHub API response")
print(f"Available keys in response: {list(pr_data.keys())}")
exit(1)
email = extract_email(pr_body, PR_URL, GITHUB_TOKEN)
print(f"📬 Found email: {email}")