#1909 Let the doc server return something even if we do not know its encoding
Merged by pingou. Opened by pingou.
invalid_encoding  into  master

Download 1909.patch

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/

This has been hotfixed in prod so that the URL above is accessible

I recommend catching a more specific Exception here, perhaps some encoding related one. I assume there could be other types of Exceptions raised from convert_readme and you might not want to handle every possible error in this manner.

I recommend adding a test to test handling an encoding problem, and another test to handle an unexpected exception (perhaps something silly like IOError).

LGTM!

As far as I can see this is the only exception raised by convert_readme

unit-tests added :)

rebased

rebased

It might be reasonable to use this:

https://docs.python.org/2/library/exceptions.html#exceptions.UnicodeError

It might be reasonable to catch this exception instead of a general pagure error:

It might be reasonable to use this:

https://docs.python.org/2/library/exceptions.html#exceptions.UnicodeError

1 new commit added

  • Raise a PagureEncodingException when none of the encoding guessed worked

rebased

I've updated the tests as advised, so merging.

Thanks for the review!!

Pull-Request has been merged by pingou

Metadata