From 6dba781aa687824c17a4af2c15bcd40a448f5813 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 16 2017 09:23:52 +0000 Subject: Let the doc server return something even if we do not know its encoding Sometime when trying to retrieve the encoding of some content, we just fail at guessing it. So far this led pagure to return a 500 error without any content. With this commit, we know catch the exception, consider the content as not safe but we will return it. This means that we will at least return something to the user. This fixes an error reported by pagure by email where it could not render https://docs.pagure.org/packaging-guidelines/ --- diff --git a/pagure/docs_server.py b/pagure/docs_server.py index 3947a63..66aad6d 100644 --- a/pagure/docs_server.py +++ b/pagure/docs_server.py @@ -111,7 +111,12 @@ def __get_tree_and_content(repo_obj, commit, path): ext = os.path.splitext(blob_or_tree.name)[1] blob_obj = repo_obj[blob_or_tree.oid] if not is_binary_string(blob_obj.data): - content, safe = pagure.doc_utils.convert_readme(blob_obj.data, ext) + try: + content, safe = pagure.doc_utils.convert_readme( + blob_obj.data, ext) + except pagure.exceptions.PagureException: + safe = False + content = blob_obj.data else: safe = True content = blob_obj.data