Issue #202: Pushing a repository via id, IE, http://example.com/_2, throws an AssertionError
|Reported by:||Lutchy Horace|
|Created on:||2016-03-29 13:51|
|Updated on:||2018-05-19 15:13|
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.
Comment by Mads Kiilerich, on 2016-03-29 14:26
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?
Comment by Sebastian Krause, on 2016-06-02 09:55
The assertion error happens here: https://kallithea-scm.org/repos/kallithea/files/8075ec3d02336e655f8110aa85d3adc9a653e96c/kallithea/lib/middleware/simplehg.py#L87
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
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.
Comment by Michael DePalatis, on 2016-06-09 16:13
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: 10.28.1.233 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.
Comment by Mads Kiilerich, on 2016-06-09 23:10
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 = by_id_match + data = safe_str(by_id_match) return '/'.join(data)
Can you confirm?
Comment by Michael DePalatis, on 2016-06-10 07:38
That works for me, thanks.
Comment by Thomas De Schampheleire, on 2018-05-19 15:13
Fixed with 110dcae69d7d