gitlabhq/gitlabhq — Issue #262: Error 500 on Login if Projects Limit is left empty
Author: wilatai
Created: 2012-01-03 14:28:52+00:00
State: open

I had just installed GitLab succesfully (first via WEBRick, later also via NGINX*) and I was playing around with it for half an hour or so, e.g. creating a new user, experimenting with permissions for a few (empty) test repositories, etc.

Suddenly after clicking logout as the Admin user, wanting to switch to another user I am getting the error below. The last changes I I could recall were:

- Making the other user an 'admin' (as the original admin user)
- Changing the password of the other user (as the original admin user)
- Earlier changing the (displayed) name of the other user (IIRC from that other users account itself)

I would now get an Error 500. Sadly I've got practically zero knowledge of Ruby, but WEBrick gave the following output:

```
bundle exec rails s -e production
=> Booting WEBrick
=> Rails 3.1.1 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-01-03 14:51:27] INFO WEBrick 1.3.1
[2012-01-03 14:51:27] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
[2012-01-03 14:51:27] INFO WEBrick::HTTPServer#start: pid=1628 port=3000
cache: [GET /] miss

Started GET "/" for 129.125.175.79 at 2012-01-03 14:51:27 +0100
Processing by DashboardController#index as HTML
Rendered dashboard/_sidebar.html.haml (3.7ms)
Rendered dashboard/index.html.haml within layouts/application (13.9ms)
Completed 500 Internal Server Error in 347ms

ActionView::Template::Error (undefined method `>' for nil:NilClass):
1: %aside
2: %h4
3: - if current_user.can_create_project?
4: %a.button-small.button-green{:href => new_project_path} New Project
5: Your Projects
6: %ol.project-list
app/models/user.rb:54:in `can_create_project?'
app/views/dashboard/_sidebar.html.haml:3:in `_app_views_dashboard__sidebar_html_haml__3812077499945998929_53015460'
app/views/dashboard/index.html.haml:4:in `_app_views_dashboard_index_html_haml__3002901999675966789_53331140'
app/controllers/dashboard_controller.rb:8:in `index'
```

Now this error persisted in the original browser (Firefox), but while I was typing the above I wanted to make really sure that it wasn't some caching issue on my side.

So I fired up IE and I got a login window.. I could log in as the Admin user .. so far so good! I played with some of the settings of the user I made admin earlier; After each change checking if Firefox could display the login page again.

Ultimately I found that the culprit was an empty field for the 'projects limit' field. Any number, including 0, is fine. Leave it empty and you get thet 500 error while trying to log in. I think it could potentially save other people time dealing with this if either the projects limit field got some validation (or a little help text) or perhaps interpreting an empty field ('no limit') as e.g. 0 or so behind the scenes is a good suggestion.

It's easy now to think: I don't want a user to have any limit, clear the field.. and suddenly you've got a login problem.

( * Following: https://github.com/gitlabhq/gitlabhq/wiki/V2.0-easy-setup-for-ubuntu Thank you SOO much for this and for GitLab, love it so far! )