Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions pr_review/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def process_pull_request(self, repo: str, pr_number: int, experience_level: str
Returns:
Processing results
"""
# Initialize results early to avoid UnboundLocalError
results = {
'pr_number': pr_number,
'repository': repo,
'status': 'error',
'error': 'Unknown error occurred'
}

try:
logger.info(f"Processing PR #{pr_number} in {repo}")

Expand Down Expand Up @@ -105,10 +113,7 @@ def process_pull_request(self, repo: str, pr_number: int, experience_level: str

self.github_client.create_issue_comment(repo, pr_number, comment_body)

# Send Discord notification
asyncio.create_task(self._send_discord_notification(results, comment_body))

# Return processing results
# Update results with success data BEFORE sending notification
results = {
'pr_number': pr_number,
'repository': repo,
Expand All @@ -119,6 +124,9 @@ def process_pull_request(self, repo: str, pr_number: int, experience_level: str
'status': 'success'
}

# Send Discord notification with properly initialized results
asyncio.create_task(self._send_discord_notification(results, comment_body))

logger.info(f"Successfully processed PR #{pr_number}")
return results

Expand Down