From 47180410a5bbac723a173fad0c9c782b8fcc4a69 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 09 2017 10:47:09 +0000 Subject: [PATCH 1/2] Ignore the ``No Content-Type`` error raised by pygit2 We recently starting running into this error for remote PR opened from a github git repo. Maybe something change in github that is now triggering this. Anyway, with this commit, we will now be ignoring that specific error and keep on going as usual. It will at least allow accessing pull-requests that have already been open and which are basically still valid. Fixes https://pagure.io/pagure/issue/1863 --- diff --git a/pagure/__init__.py b/pagure/__init__.py index dc0f402..000048b 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -614,12 +614,14 @@ def get_remote_repo_path(remote_git, branch_from, loop=False): try: repo.pull(branch=branch_from, force=True) except pygit2.GitError as err: - LOG.exception(err) - flask.abort( - 500, - 'The following error was raised when trying to pull the ' - 'changes from the remote: %s' % str(err) - ) + LOG.debug('Error pull the repo: %s -- error: %s' % (repopath, err)) + if str(err) != 'No Content-Type header in response': + LOG.exception(err) + flask.abort( + 500, + 'The following error was raised when trying to pull the ' + 'changes from the remote: %s' % str(err) + ) except pagure.exceptions.PagureException as err: LOG.exception(err) flask.abort(500, str(err)) From d0ec1f7db370a4e65b3c425c15bcd4b35e9127a6 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 09 2017 10:47:09 +0000 Subject: [PATCH 2/2] Ignore case when checking the GitError raised It looks like a future version of libgit2 is going to change the case of its error message: https://github.com/libgit2/libgit2/commit/909d5494368a00809bc42f4780e86f4dd66e4422 So in order to be forward compatible, let's just ignore the case when we perform our check. --- diff --git a/pagure/__init__.py b/pagure/__init__.py index 000048b..8cfce94 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -615,7 +615,7 @@ def get_remote_repo_path(remote_git, branch_from, loop=False): repo.pull(branch=branch_from, force=True) except pygit2.GitError as err: LOG.debug('Error pull the repo: %s -- error: %s' % (repopath, err)) - if str(err) != 'No Content-Type header in response': + if str(err).lower() != 'no content-type header in response': LOG.exception(err) flask.abort( 500,