mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 05:10:38 +08:00
Add detailed logging and error handling in GitHub polling server
- Introduce traceback logging for exceptions during notification processing. - Enhance logging for PR comments with additional artifact information. - Update configuration settings for publishing PR descriptions as comments.
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
|
import traceback
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
@ -35,6 +36,7 @@ async def polling_loop():
|
|||||||
user_id = git_provider.get_user_id()
|
user_id = git_provider.get_user_id()
|
||||||
agent = PRAgent()
|
agent = PRAgent()
|
||||||
get_settings().set("CONFIG.PUBLISH_OUTPUT_PROGRESS", False)
|
get_settings().set("CONFIG.PUBLISH_OUTPUT_PROGRESS", False)
|
||||||
|
get_settings().set("pr_description.publish_description_as_comment", True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
deployment_type = get_settings().github.deployment_type
|
deployment_type = get_settings().github.deployment_type
|
||||||
@ -92,7 +94,8 @@ async def polling_loop():
|
|||||||
comment_body = comment['body'] if 'body' in comment else ''
|
comment_body = comment['body'] if 'body' in comment else ''
|
||||||
commenter_github_user = comment['user']['login'] \
|
commenter_github_user = comment['user']['login'] \
|
||||||
if 'user' in comment else ''
|
if 'user' in comment else ''
|
||||||
get_logger().info(f"Commenter: {commenter_github_user}\nComment: {comment_body}")
|
get_logger().info(f"Polling, pr_url: {pr_url}",
|
||||||
|
artifact={"comment": comment_body})
|
||||||
user_tag = "@" + user_id
|
user_tag = "@" + user_id
|
||||||
if user_tag not in comment_body:
|
if user_tag not in comment_body:
|
||||||
continue
|
continue
|
||||||
@ -100,7 +103,8 @@ async def polling_loop():
|
|||||||
comment_id = comment['id']
|
comment_id = comment['id']
|
||||||
git_provider.set_pr(pr_url)
|
git_provider.set_pr(pr_url)
|
||||||
success = await agent.handle_request(pr_url, rest_of_comment,
|
success = await agent.handle_request(pr_url, rest_of_comment,
|
||||||
notify=lambda: git_provider.add_eyes_reaction(comment_id)) # noqa E501
|
notify=lambda: git_provider.add_eyes_reaction(
|
||||||
|
comment_id)) # noqa E501
|
||||||
if not success:
|
if not success:
|
||||||
git_provider.set_pr(pr_url)
|
git_provider.set_pr(pr_url)
|
||||||
|
|
||||||
@ -108,7 +112,8 @@ async def polling_loop():
|
|||||||
print(f"Failed to fetch notifications. Status code: {response.status}")
|
print(f"Failed to fetch notifications. Status code: {response.status}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
get_logger().error(f"Exception during processing of a notification: {e}")
|
get_logger().error(f"Polling exception during processing of a notification: {e}",
|
||||||
|
artifact={"traceback": traceback.format_exc()})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user