From f51eb93d3ea92231e72247266df6df2d024db826 Mon Sep 17 00:00:00 2001 From: Rohit Malhotra Date: Sun, 9 Mar 2025 17:45:13 -0400 Subject: [PATCH] Add error logs to API response from GH Service (#7165) --- openhands/integrations/github/github_service.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openhands/integrations/github/github_service.py b/openhands/integrations/github/github_service.py index 47552ef458..24b87b6ecc 100644 --- a/openhands/integrations/github/github_service.py +++ b/openhands/integrations/github/github_service.py @@ -14,7 +14,7 @@ from openhands.integrations.github.github_types import ( TaskType, ) from openhands.utils.import_utils import get_impl - +from openhands.core.logger import openhands_logger as logger class GitHubService: BASE_URL = 'https://api.github.com' @@ -80,9 +80,12 @@ class GitHubService: except httpx.HTTPStatusError as e: if e.response.status_code == 401: raise GhAuthenticationError('Invalid Github token') + + logger.warning(f"Status error on GH API: {e}") raise GHUnknownException('Unknown error') - except httpx.HTTPError: + except httpx.HTTPError as e: + logger.warning(f"HTTP error on GH API: {e}") raise GHUnknownException('Unknown error') async def get_user(self) -> GitHubUser: @@ -174,9 +177,12 @@ class GitHubService: except httpx.HTTPStatusError as e: if e.response.status_code == 401: raise GhAuthenticationError('Invalid Github token') + + logger.warning(f"Status error on GH API: {e}") raise GHUnknownException('Unknown error') - except httpx.HTTPError: + except httpx.HTTPError as e: + logger.warning(f"HTTP error on GH API: {e}") raise GHUnknownException('Unknown error') async def get_suggested_tasks(self) -> list[SuggestedTask]: