Trouble with (urlencoding)


Just following the githib issue template recommendation :slight_smile:

I am toying with gerrit as remote and found the problem I dont know how to resolve.
The is urlencoded - ie “Project%231” or “Some%2FOther%2FProject”. It goes fine to browsers(Chrome and FF) and back to drone server (confirmed with wireshark).

But seems gin does urldecode even before splitting url for params - so the post /api/repos/Some%2FOther%2FProject doesnt hit PostRepo at all :S
and for post /api/repos/Project%231 c.Param(“name”) return “Project#1”.

Any advice?


Drone expects the full name, otherwise known as slug format:


The router registers the handler paths assuming this format:


So for example the repository drone/envsubst would have the below endpoint. Note the slash in the slug is not url encoded:


The {owner}/{name} slug format is compatible with GitHub / GitLab / Gogs / Bitbucket. What format does Gerrit use for its repository names?

The for instance is the urlencoded string - i.e. to hide the /.
So it takes somethings as /projects/Some%2FOther%2FProject just fine.

This problem is due to gin actually - it uses url.Path which urldecoded by golang url.Parse while it shall use url.RawPath (there is PR to fix it). So the gin missing URI components boundaries.

There are gin maintainers that are also drone maintainers, so if you message tboerger or appleboy in in the room they may be able to advise.

Note if the referenced pull request were merged, POST /api/repos/Some%2FOther%2FProject would still not match POST /api/repos/{owner}/{name}.

The Gerrit project name will need to match {owner}/{name}. If Gerrit does not have a concept of {owner} a dummy value such as gerrit/{name} or _/{name} could be used, allowing it to match {owner}/{name}. Either way, we would need some sort of workaround here.

Thanks for advice! I will drop message to them!

I am toying with gerrit as remote for drone (one which is not yet implemented). So far I am using anonymous access (no actual login and fake model.User).
But this problem was seen when I was not able to enable repo via drone-ui. In my case the log was showing
POST /api/repos/anonymous/Some/Other/Project and it did not hit any routes due to gin problem.