gitblit-org / gitblit

pure java git solution
http://gitblit.com
Apache License 2.0
2.28k stars 670 forks source link

Branch browsing fails with 404 #307

Closed gitblit closed 9 years ago

gitblit commented 9 years ago

Originally reported on Google Code with ID 11

What steps will reproduce the problem?
1. go to summary page and select a repository
2. select a branch
3. click over the branch name (second column)

What is the expected output? What do you see instead?
The system should display the repository content for the selected branch.
Instead, the system fails with a 404 because the branch path is incorrectly
URL-encoded: the URL should be /<reponame>/refs/heads/<branchname> 
but it is /<reponame>/refs%2Fheads%2F<branchname> 

What version of the product are you using? On what operating system?
0.5.1

Please provide any additional information below.

Reported by gm.romanato on 2011-07-14 08:23:34

gitblit commented 9 years ago
Hi.  I'm going to take a guess that you are using the WAR variant because I can't get
the GO variant to fail as you've described with FF4, Chrome 12, Opera 11.5, or IE 9.

Assuming you are using the WAR variant, what is your servlet container?  If you are
using the GO variant, what OS?

Reported by James.Moger on 2011-07-14 12:04:49

gitblit commented 9 years ago
I confirm that the WAR variant on Tomcat 6 seems to have trouble with the URLs.  The
urls are automatically encoded and decoded by Wicket, the web framework used by gitblit.
 I'll see if I can control that better.

In the meantime you can set web.mountParameters = false in your web.xml or gitblit.properties
file.  This will switch from pretty urls to standard ?a=b&c=d urls.

Reported by James.Moger on 2011-07-14 12:14:14

gitblit commented 9 years ago
I confirm that changing web.mountParameters to true works around the issue.

I am using the GO variant on a CentOS 5.5 x64 Linux distribution, JVM version is: 
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

Thanks a lot.

Reported by gm.romanato on 2011-07-14 15:57:59

gitblit commented 9 years ago
I've been looking into this issue some more and while there is a problem with '/' chars
for Tomcat >= 6.0.10 (Tomcat forbids their usage, actually) - I can not reproduce your
problem with GO (embedded Jetty) on Ubuntu with FF, Chrome, or Opera.

Could you set:
web.debugMode = true
web.mountParameters = true

and then attempt to browse to your branch?

I'd like a copy of the stdout log that you get which may have some relevant info for
me.

Reported by James.Moger on 2011-07-21 17:58:31

gitblit commented 9 years ago

Reported by James.Moger on 2011-07-21 18:53:38

gitblit commented 9 years ago
At the moment I cannot execute the requested test because gitblit has stopped working.
See issue #310

Reported by gm.romanato on 2011-07-22 14:36:37

gitblit commented 9 years ago
Here is the output with the changed settings: 

********************************************************************
*** WARNING: Wicket is running in DEVELOPMENT mode.              ***
***                               ^^^^^^^^^^^                    ***
*** Do NOT deploy to your live server(s) without changing this.  ***
*** See Application#getConfigurationType() for more information. ***
********************************************************************
log 
INFO  Setting up user service /home/rad/gitblit/users.properties
INFO  jetty-7.4.2.v20110526
INFO  Shutdown Monitor listening on port 8081
INFO  Extract jar:file:/home/rad/gitblit/gitblit.jar!/ to /tmp/gitblit/webapp
INFO  NO JSP Support for /, did not find org.apache.jasper.servlet.JspServlet
INFO  started o.e.j.w.WebAppContext{/,file:/tmp/gitblit/webapp/},file:/home/rad/gitblit/gitblit.jar
INFO  [GitBlitWebApp] init: Wicket core library initializer
INFO  [GitBlitWebApp] init: Wicket extensions initializer
INFO  [GitBlitWebApp] Started Wicket version 1.4.17 in development mode
INFO  Started SelectChannelConnector@10.0.0.4:8080 STARTING
INFO  Loading properties files from jar:file:/home/rad/gitblit/gitblit.jar!/com/gitblit/wicket/GitBlitWebApp.properties
INFO  Loading properties files from jar:file:/home/rad/gitblit/ext/wicket-1.4.17.jar!/org/apache/wicket/Application.properties

Unluckily, the server does not seem to output anything. 
Here is the URL format that is requested when I click on a branch and which fails:

http://<hostname>/log/<reponame>/refs%2Fheads%2F<branchname>

Reported by gm.romanato on 2011-07-22 15:48:13

gitblit commented 9 years ago
I still can't get an error.  Does the branch name or repo name use non-ascii characters?
 Is a copy of the repo publicly accessible?

Reported by James.Moger on 2011-07-25 20:51:32

gitblit commented 9 years ago
Name contains letters, numbers and dots e.g ab.defg123.git

Unluckily no, the repo is not publicly accessible, and I cannot even create a dummy
repository for you as we use gitolite for access control and I would need to have the
sysadmins create ssh keys for you etc etc.

If you believe the O.S. may be the cause, did you try creating a virtual machine running
centos 5.5 ?

Could it be that the problem is related to this Wicket issue? https://issues.apache.org/jira/browse/WICKET-2125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

In any case, to me the severity of the issue is low, because I just set web.mountParameters
= false and everything works fine. 

Reported by gm.romanato on 2011-07-26 08:27:07

gitblit commented 9 years ago
I don't really think its the OS.  I may create a vm, but am trying to avoid that if
possible.  So to review, with web.mountParameters=true, you click on a branch from
the summary page to view its log and you get a 404.  And this happens on any branch
in any of your repositories?  If that is the case I'm baffled why I can't reproduce
it.

As far as a dummy repo (could be zipped & attached), that would only be useful if you
think that there is something about your repo that might be unusual.  i.e. like your
vcs-import repo where head pointed to nothing but there was an active branch.

Reported by James.Moger on 2011-07-26 12:17:48

gitblit commented 9 years ago
I believe it happens with any repo: I just tried 3 or 4 randomly selected out of 90
repos and all failed.

And unluckily the repos are very standard, nothing unusual.

I could start the JVM in debug mode, remote-connect to the gitblit process using the
Eclipse debugger and, with some hints from you, try to figure out what's going on or
collect some more information for you. However I guess we will have to wait till next
week at best before I can dedicate some time to this.

Reported by gm.romanato on 2011-07-27 12:32:54

gitblit commented 9 years ago
It bothers me that it is 100% reproducible for you and 0% for me, but lets shelve it
for now.  I'll try to make some time to get CentOS 5.5 x64 running in a vm.

BTW, I release 0.5.2 this morning.

Reported by James.Moger on 2011-07-27 12:52:38

gitblit commented 9 years ago
We're having the same problem using Tomcat 6 on Ubuntu Server 11.04.

URL: http://git.mydomain.com/gitblit/tree/project.git/1936d3fdf3dc5de3486845d543427gid09dec84c/transformNode%2Fsrc

We're running through an Apache proxy which gives a 404 error, talking direct to Tomcat
produces a blank page.

We have also found that we can't get to the summary page for grouped repositories,
e.g we create a repository called "myGroup/myProject", the repository works fine but
we can't get to the summary page.

URL: http://git.mydomain.com/gitblit/summary/myGroup%2FmyProject.git

I guess it's the same problem.

Reported by james@jbench.co.uk on 2011-10-25 12:35:47

gitblit commented 9 years ago
If you are running Gitblit through a proxy you MUST ensure that the proxy is not decoding
embedded forward slashes and then re-encoding them.  In your case this is almost definitely
what is happening.  Newer version of Apache have the following config option.  You
may be able to find some combination that also works.

http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes

If you switch from mounted urls to parameterized urls (web.mountParameters=false),
this problem goes away.

The other tricky thing to note about Tomcat is that Tomcat itself does not like embedded
slashes (http://tomcat.apache.org/security-6.html#Fixed_in_Apache_Tomcat_6.0.10). 
You can control this in Gitlbit with web.forwardSlashCharacter or web.mountParameters,
or you can tweak Tomcat.

Reported by James.Moger on 2011-10-25 12:50:31

gitblit commented 9 years ago
I can not reproduce this as a bug outside the workarounds/settings I have outlined.
Closing.

Reported by James.Moger on 2012-01-11 21:49:08