Kallithea issues archive

Issue #24: Clicking on git changesets fails: 'name' must be bytestring, not unicode URL

Reported by: Michael DePalatis
State: resolved
Created on: 2014-08-30 13:31
Updated on: 2015-02-06 13:36


When clicking on a changeset in a git repository, I get a 500 Internal Server Error page. This is running Kallithea via uwsgi. The key error appears to be related to unicode being passed instead of a bytestring:

Error - <type 'exceptions.TypeError'>: 'name' must be bytestring, not unicode
URL: http://iontrap.phys.au.dk:5001/iontrap/address_list/changeset/790b5fb99094ad459e4e572c68a04b05a1b630bf

The full output from uwsgi including traceback is attached.




Comment by Mads Kiilerich, on 2014-08-30 14:18

Do you see that on all changesets or only on ones with non-ascii chars?

Is the server side running with LANG=C (which could explain this) or is it using UTF-8?

Comment by Michael DePalatis, on 2014-08-31 07:53

I tried clicking on several commits in git repositories, and they all give the 500 error. Interestingly, this does not happen with any Mercurial repositories. Clicking on those commit summaries shows the full commit message as well as the diffs as expected.

If you mean the LANG environment variable, I see en_US.UTF-8 when I echo $LANG.

Comment by Mads Kiilerich, on 2014-08-31 08:20

Weird - in other setups it works.

Are you sure you are looking at the LANG in exactly the right "context"? You can try to check /proc/XXX/environ .

Do this mitigate the problem?

--- a/kallithea/lib/vcs/backends/git/changeset.py
+++ b/kallithea/lib/vcs/backends/git/changeset.py
@@ -27,11 +27,11 @@ class GitChangeset(BaseChangeset):
     def __init__(self, repository, revision):
         self._stat_modes = {}
         self.repository = repository
+        revision = safe_str(revision)
-            commit = self.repository._repo[str(revision)]
+            commit = self.repository._repo[revision]
             if isinstance(commit, objects.Tag):
-                revision = commit.object[1]
+                revision = safe_str(commit.object[1])
                 commit = self.repository._repo.get_object(commit.object[1])
         except KeyError:
             raise RepositoryError("Cannot get object with id %s" % revision)

Comment by Michael DePalatis, on 2014-08-31 09:10

The patch solves the problem. Thanks!

For completeness, I also checked that /proc/XXX/environ contained the proper LANG variable, which it does (i.e., en_US.UTF8).

Comment by Mads Kiilerich, on 2014-08-31 12:51


Comment by Mads Kiilerich, on 2014-09-25 10:12

Comment by Daniel Faust, on 2015-02-06 11:05

Hi, just so you know: this fix hasn't yet been propagated to pypi.

Comment by Mads Kiilerich, on 2015-02-06 13:36

Yes, we are hoping to get a release out soon.

I can recommend running from a repo checkout. I make sure that is so stable that I can use it in production. You can make it (and the next release) even better if you help verify that.