From 17c6eefabe1c7e22b1cd7e62caa675128af79ee7 Mon Sep 17 00:00:00 2001 From: Daniel King Date: Mon, 6 Apr 2020 17:52:06 -0400 Subject: [PATCH] [ci] better errors on bad github response Not sure what was wrong, but CI was getting 422s from GitHub. Using a `raise_for_status=True` ClientSession circumvented gidgethubs native error handling logic smothering the HTTP response body where github places critical debugging information. Aiohttp is aware that `raise_for_status` provides no access to the response body. They addressed this in https://github.com/aio-libs/aiohttp/pulls/3892, but that has not been released because 4.0.0 has not yet been released. Another relevant issue: https://github.com/aio-libs/aiohttp/issues/4600. --- ci/ci/ci.py | 6 +++++- ci/ci/github.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ci/ci/ci.py b/ci/ci/ci.py index 1585cf6dc20..8881f09a134 100644 --- a/ci/ci/ci.py +++ b/ci/ci/ci.py @@ -323,7 +323,11 @@ async def on_startup(app): raise_for_status=True, timeout=aiohttp.ClientTimeout(total=60)) app['client_session'] = session - app['github_client'] = gh_aiohttp.GitHubAPI(session, 'ci', oauth_token=oauth_token) + app['github_client'] = gh_aiohttp.GitHubAPI( + aiohttp.ClientSession( + timeout=aiohttp.ClientTimeout(total=60)), + 'ci', + oauth_token=oauth_token) app['batch_client'] = await BatchClient('ci', session=session) with open('/ci-user-secret/sql-config.json', 'r') as f: diff --git a/ci/ci/github.py b/ci/ci/github.py index a7f8b68bdb1..539e7f493e1 100644 --- a/ci/ci/github.py +++ b/ci/ci/github.py @@ -309,7 +309,7 @@ async def post_github_status(self, gh_client, gh_status): except gidgethub.HTTPException as e: log.info(f'{self.short_str()}: notify github of build state failed due to exception: {e}') except aiohttp.client_exceptions.ClientResponseError as e: - log.error(f'{self.short_str()}: Unexpected exception in post to github: {e}') + log.exception(f'{self.short_str()}: Unexpected exception in post to github: {data} {e}') async def _update_github(self, gh): await self._update_last_known_github_status(gh)