Pushing a repository via id, IE, http://example.com/_2, throws an AssertionError

Issue #202 resolved
Lutchy Horace created an issue


Kallithea version: 0.3

Python version: 2.7.5

When pushing a repository via repository id, I get an:

ERROR [kallithea.lib.middleware.simplehg] error extracting repo_name: AssertionError()

On the hand, while pushing via by name, this completes successfully. Any additional infomation you may need from me, please don't hesitate to ask.

Regards, Horace

Comments (6)

  1. Mads Kiilerich

    Are you running it as paster serve or getting error mails? Then there should be an interesting stack trace.

    Can you confirm it works when accessing with name?

    Also, what is your use case for using the ID instead of the name?

  2. Sebastian Krause

    The assertion error happens here: https://bitbucket.org/conservancy/kallithea/src/8075ec3d02336e655f8110aa85d3adc9a653e96c/kallithea/lib/middleware/simplehg.py?at=default&fileviewer=file-view-default#simplehg.py-87

    The reason is that str_repo_name is of type unicode when we use the repository id, but normally it's str and the remaining of of the module also doesn't seem to work with unicode anyway.

    I think the fix is simple: Just wrap the return repo.repo_name in lib.utils.get_repo_by_id() into a safe_str, then it already works here.

  3. Michael DePalatis

    I am having this same problem. I get logs that look something like this:

    2016-06-07 16:24:26.172 DEBUG [kallithea.lib.middleware.simplegit] pathinfo: /_3
    3 detected as Git False
    2016-06-07 16:24:26.172 DEBUG [kallithea.lib.middleware.simplehg] pathinfo: /_33
     detected as Mercurial True
    2016-06-07 16:24:26.180 ERROR [kallithea.lib.middleware.simplehg] error extracting repo_name: AssertionError()
    2016-06-07 16:24:26.180 DEBUG [kallithea.SimpleHg] Request time: 0.008s
    2016-06-07 16:24:26.181 DEBUG [kallithea.SimpleGit] Request time: 0.009s
    2016-06-07 16:24:26.181 INFO  [kallithea.RequestWrapper] IP: Request to /etherDAC/etherDAC time: 0.009s

    From the last line, there is apparently no real problem in resolving the name, but the push fails nonetheless.

    @kiilerix the use case for me is so that I have permanent URLs: if I later move where I am categorizing a repository, I don't have to change the URL in every local copy. This is especially useful when using subrepositories (a practice I don't condone but unfortunately inherited a lot of those).

    At least for now, @sekrause's workaround seems to fix the problem for me. It would be nice to get this change upstream.

  4. Mads Kiilerich

    The correct fix seems to be

    --- a/kallithea/lib/base.py
    +++ b/kallithea/lib/base.py
    @@ -202,7 +202,7 @@ class BaseVCSController(object):
                 from kallithea.lib.utils import get_repo_by_id
                 by_id_match = get_repo_by_id(repo_name)
                 if by_id_match:
    -                data[1] = by_id_match
    +                data[1] = safe_str(by_id_match)
             return '/'.join(data)

    Can you confirm?

  5. Log in to comment