From 7bfba4bc3402194c3de8c00ec59429094a0690bf Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 10 2017 20:59:14 +0000 Subject: Fix retrieving a file from the git repo This fixes an error that has been reported by email from the production instance of pagure.io Basically, when trying to access the specified blob in the repo, git said it does not know it, so we'll assume that the ref is invalid and just bail. --- diff --git a/pagure/__init__.py b/pagure/__init__.py index 4dcf7de..4be9faa 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -569,7 +569,12 @@ def __get_file_in_tree(repo_obj, tree, filepath, bail_on_tree=False): return blob else: - nextitem = repo_obj[entry.oid] + try: + nextitem = repo_obj[entry.oid] + except KeyError: + # We could not find the blob/entry in the git repo + # so we bail + return # If we can't get the content (for example: an empty folder) if nextitem is None: return