Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 500 on repository creation & edit #484

Closed
clee231 opened this issue Jul 23, 2015 · 14 comments
Closed

Error 500 on repository creation & edit #484

clee231 opened this issue Jul 23, 2015 · 14 comments
Assignees
Labels
Milestone

Comments

@clee231
Copy link

clee231 commented Jul 23, 2015

Hi,

I recently upgraded from Redmine 2.6.0 ->3.0.4 & redmine_git_hosting 0.7.8 -> 1.1.1.

I'm running into a 500 error anytime I create a repository and/or edit a existing repository.

Relevant production error log messages:

Started GET "/redmine/projects/testproj/repositories/new?repository_scm=Xitolite" for 98.226.58.246 at 2015-07-22 21:52:43 -0500
Processing by RepositoriesController#new as JS
  Parameters: {"repository_scm"=>"Xitolite", "project_id"=>"testproj"}
  Current user: clee231 (id=7)
  Rendered repositories/_form.html.erb (5.8ms)
  Rendered repositories/new.html.erb (8.0ms)
  Rendered repositories/new.js.erb (8.9ms)
Completed 200 OK in 56ms (Views: 10.7ms | ActiveRecord: 8.5ms)
Started POST "/redmine/projects/testproj/repositories" for 98.226.58.246 at 2015-07-22 21:52:57 -0500
Processing by RepositoriesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"8dEdibDYPP/6XYsJFaKeRi9X7qTZNA+H3IfAkEjZdMgklkScuV3kH84fKLI5CicPvLnQ5qp4ak3==", "repository_scm"=>"Xitolite", "repository"=>{"is_default"=>"1", "identifier"=>"tester", "path_encoding"=>"UTF-8", "create_readme"=>"false", "enable_git_annex"=>"false"}, "commit"=>"Create", "project_id"=>"testproj"}
  Current user: clee231 (id=7)
Redirected to http://mememe.local/redmine/projects/testproj/settings/repositories
Completed 500 Internal Server Error in 2369ms (ActiveRecord: 34.6ms)

TypeError (no implicit conversion of nil into Array):
  app/models/repository/git.rb:75:in `branches'
  app/models/repository/git.rb:130:in `fetch_changesets'
Started GET "/redmine/repositories/2/edit" for 98.226.58.246 at 2015-07-22 22:26:03 -0500
Processing by RepositoriesController#edit as HTML
  Parameters: {"id"=>"2"}
  Current user: clee231 (id=7)
  Rendered plugins/redmine_bootstrap_kit/app/views/common/_modal_base.html.haml (0.5ms)
  Rendered plugins/redmine_git_hosting/app/views/common/_git_hosting_js_headers.html.haml (3.8ms)
  Rendered plugins/redmine_git_hosting/app/views/common/_git_urls.html.haml (13.0ms)
  Rendered plugins/redmine_git_hosting/app/views/repositories/_edit_top.html.haml (24.4ms)
  Rendered repositories/_form.html.erb (9.0ms)
  Rendered plugins/redmine_git_hosting/app/views/repositories/_xitolite_options.html.haml (15.5ms)
  Rendered plugins/redmine_git_hosting/app/views/repositories/edit.html.haml within layouts/base (65.8ms)
Completed 500 Internal Server Error in 110ms (ActiveRecord: 8.6ms)

ActionView::Template::Error (no implicit conversion of nil into Array):
    35:
    36:               %p
    37:                 = label_tag 'repository_git_extra[default_branch]', l(:label_repository_default_branch)
    38:                 - if !repository.branches.empty?
    39:                   = f.select :default_branch, repository_branches_list(repository.branches)
    40:                 - else
    41:                   %span{ class: 'label label-info' }= repository.git_default_branch
  app/models/repository/git.rb:75:in `branches'

Here is the environment information from admin/info:

Environment:
  Redmine version                3.0.4.stable
  Ruby version                   2.1.5-p273 (2014-11-13) [x86_64-linux]
  Rails version                  4.2.3
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.6.11
  Git                            1.7.1
  Filesystem                     
  Xitolite                       1.7.1
Redmine plugins:
  redmine_bootstrap_kit          0.2.3
  redmine_git_hosting            1.1.1

The main error seems to be no implicit conversion of nil into Array. This makes me think that some data in the database is not correct. I'm not sure where it would be though. Does anyone have any insight? Thanks!

@n-rodriguez
Copy link
Contributor

It seems that your repository has the wrong repository type : Repository::Git instead of Repository::Xitolite. Can you check this in your database?

@n-rodriguez n-rodriguez self-assigned this Jul 23, 2015
@clee231
Copy link
Author

clee231 commented Jul 24, 2015

I've changed one of the repository types to Repository:Git, however now the repository page just returns a 404. I am able to view the edit page though.

Should the repository type not be set to Xitolite? These repositories and its access permissions should be managed by Gitolite.

@n-rodriguez
Copy link
Contributor

Should the repository type not be set to Xitolite? These repositories and its access permissions should be managed by Gitolite.

Yes : if the repository is managed by Gitolite the repo type must be Repository::Xitolite

@clee231
Copy link
Author

clee231 commented Jul 24, 2015

They are Gitolite-managed repositories.
Xitolite should be the correct repository type. Do you know of anything else that could be causing the 500 error? Is there anything in particular that I should be looking for?

@n-rodriguez
Copy link
Contributor

Do you know of anything else that could be causing the 500 error? Is there anything in particular that I should be looking for?

You get this error if the repository doesn't exist on Gitolite side (in <git user homedir>/repositories/) or if the repo has not been correctly initialized on creation.

@clee231
Copy link
Author

clee231 commented Jul 24, 2015

Hmm... So how do I initialize the repository correctly? I still receive the aforementioned 500 error when creating a new repository and/or editing a Gitolite repository via redmine.

After the 500 error on creation of a new repo, it seems that redmine creates the correct configuration in the gitolite-admin repo:

repo    testproj/tester
  RW+                            = redmine_clee231_7
  RW                             = redmine_user1_18 redmine_user2_26 redmine_user3_27
  R                              = gitweb
  config redminegitolite.projectid = testproj
  config redminegitolite.repositoryid = tester
  config redminegitolite.repositorykey = oTwRpqU7nryXXXXXSN5o8gOW0IozADKXjpXXXxxXDw1w6fGzENaPNyF2jtXXXXX
  config http.uploadpack = true
  config http.receivepack = true
  config multimailhook.enabled = false

I am also able to push normally to the repo after adding it to redmine... however there seems to be a issue with the hooks:

$ git push
Enter passphrase for key '/home/clee231/.ssh/id_rsa':
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 271 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)

Notifying Redmine about changes to this repository : 'testproj/tester' ...
  - Error while notifying Redmine ! (status code: 404)

Calling additional post-receive hooks...
  - Executing extra hook 'hooks/post-receive.d/mail_notifications'
    multimailhook is disabled

To ssh://git@mememe.local/testproj/tester.git
   97670b0..50ae898  master -> master

Under the <git user homedir>/repositories/, I see what seems to be the correct folder structure:

$ su git
$ cd ~/repositories/
$ tree
.
├── testproj
│   ├── tester.git
│   │   ├── branches
│   │   ├── config
│   │   ├── gl-conf
│   │   ├── HEAD
│   │   ├── hooks
│   │   │   ├── applypatch-msg.sample
│   │   │   ├── commit-msg.sample
│   │   │   ├── lib -> /opt/gitolite/local/hooks/common/lib
│   │   │   ├── post-commit.sample
│   │   │   ├── post-receive -> /opt/gitolite/local/hooks/common/post-receive
│   │   │   ├── post-receive.d -> /opt/gitolite/local/hooks/common/post-receive.d
│   │   │   ├── post-receive.sample
│   │   │   ├── post-update.sample
│   │   │   ├── pre-applypatch.sample
│   │   │   ├── pre-commit.sample
│   │   │   ├── prepare-commit-msg.sample
│   │   │   ├── pre-rebase.sample
│   │   │   ├── update -> /opt/gitolite/.gitolite/hooks/common/update
│   │   │   └── update.sample
│   │   ├── info
│   │   │   └── exclude
│   │   ├── objects
│   │   │   ├── info
│   │   │   └── pack
│   │   └── refs
│   │       ├── heads
│   │       └── tags
│   └── subtest
│       └── subtestrepo.git
│           ├── branches
│           ├── config
│           ├── gl-conf
│           ├── HEAD
│           ├── hooks
│           │   ├── applypatch-msg.sample
│           │   ├── commit-msg.sample
│           │   ├── lib -> /opt/gitolite/local/hooks/common/lib
│           │   ├── post-commit.sample
│           │   ├── post-receive -> /opt/gitolite/local/hooks/common/post-receive
│           │   ├── post-receive.d -> /opt/gitolite/local/hooks/common/post-receive.d
│           │   ├── post-receive.sample
│           │   ├── post-update.sample
│           │   ├── pre-applypatch.sample
│           │   ├── pre-commit.sample
│           │   ├── prepare-commit-msg.sample
│           │   ├── pre-rebase.sample
│           │   ├── update -> /opt/gitolite/.gitolite/hooks/common/update
│           │   └── update.sample
│           ├── info
│           │   └── exclude
│           ├── objects
│           │   ├── info
│           │   └── pack
│           │       ├── pack-2f7bb69ca5ee85825edf600f0b81facbc3cdc224.idx
│           │       └── pack-2f7bb69ca5ee85825edf600f0b81facbc3cdc224.pack
│           └── refs
│               ├── heads
│               │   └── master
│               └── tags
├── gitolite-admin.git
│   ├── branches
│   ├── COMMIT_EDITMSG
│   ├── config
│   ├── description
│   ├── gl-conf
│   ├── HEAD
│   ├── hooks
│   │   ├── applypatch-msg.sample
│   │   ├── commit-msg.sample
│   │   ├── lib -> /opt/gitolite/local/hooks/common/lib
│   │   ├── post-commit.sample
│   │   ├── post-receive -> /opt/gitolite/local/hooks/common/post-receive
│   │   ├── post-receive.d -> /opt/gitolite/local/hooks/common/post-receive.d
│   │   ├── post-receive.sample
│   │   ├── post-update -> /opt/gitolite/.gitolite/hooks/gitolite-admin/post-update
│   │   ├── post-update.sample
│   │   ├── pre-applypatch.sample
│   │   ├── pre-commit.sample
│   │   ├── prepare-commit-msg.sample
│   │   ├── pre-rebase.sample
│   │   ├── update -> /opt/gitolite/.gitolite/hooks/common/update
│   │   └── update.sample
│   ├── index
│   ├── info
│   │   └── exclude
│   ├── logs
│   │   ├── HEAD
│   │   └── refs
│   │       └── heads
│   │           └── master
│   ├── objects
│   │   ├── 09
│   │   │   └── 7e785a72b7aeXXXXXd9078882ca9f7715XXXXX
│   │   ├── 0d
│   │   │   └── d38b7fa6adc35XXXXX804dd9583ae4c94XXXXX
│   │   ├── 17
│   │   │   └── d6b65bc011df2XXXXXb3e2ed19ee977ddXXXXX
│   │   ├── 19
│   │   │   └── (Omitting the rest of these object files... there are many!)
│   │   ├── info
│   │   └── pack
│   └── refs
│       ├── heads
│       │   └── master
│       └── tags
└── testing.git
    ├── branches
    ├── config
    ├── git-daemon-export-ok
    ├── gl-conf
    ├── HEAD
    ├── hooks
    │   ├── applypatch-msg.sample
    │   ├── commit-msg.sample
    │   ├── lib -> /opt/gitolite/local/hooks/common/lib
    │   ├── post-commit.sample
    │   ├── post-receive -> /opt/gitolite/local/hooks/common/post-receive
    │   ├── post-receive.d -> /opt/gitolite/local/hooks/common/post-receive.d
    │   ├── post-receive.sample
    │   ├── post-update.sample
    │   ├── pre-applypatch.sample
    │   ├── pre-commit.sample
    │   ├── prepare-commit-msg.sample
    │   ├── pre-rebase.sample
    │   ├── update -> /opt/gitolite/.gitolite/hooks/common/update
    │   └── update.sample
    ├── info
    │   └── exclude
    ├── objects
    │   ├── info
    │   └── pack
    └── refs
        ├── heads
        └── tags

92 directories, 117 files

I'm still not sure what is causing the error... any ideas?

@n-rodriguez
Copy link
Contributor

Is everything green in Administration -> Redmine Git Hosting -> Check Tests ?

@clee231
Copy link
Author

clee231 commented Jul 24, 2015

Yes, everything seem to be normal to my eyes in the config tests. See attached picture.
redmine-git-test-all-green

@michaelkrupp
Copy link

I'm running into the same issue here with Redmine 3.0.3 and RGH v1.1.1.

The RGH v1.0.x branch is working perfectly fine for me.

@clee231
Copy link
Author

clee231 commented Jul 27, 2015

Hmm..
I have regressed to version 1.0.7 of redmine_git_hosting.
I still seem to be experiencing the same errors.

On creation of a new repository:

Started GET "/redmine/projects/testproj/repositories/new?repository_scm=Xitolite" for 98.226.58.246 at 2015-07-27 14:05:12 -0500
Processing by RepositoriesController#new as JS
  Parameters: {"repository_scm"=>"Xitolite", "project_id"=>"testproj"}
  Current user: clee231 (id=7)
  Rendered repositories/_form.html.erb (7.8ms)
  Rendered repositories/new.html.erb (19.9ms)
  Rendered repositories/new.js.erb (22.5ms)
Completed 200 OK in 127ms (Views: 44.3ms | ActiveRecord: 5.5ms)
Started POST "/redmine/projects/testproj/repositories" for 131.193.177.190 at 2015-07-27 14:05:19 -0500
Processing by RepositoriesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"FM3fakeJy4kfn7RLfYckWSemFakeYxUbokdkFakexE2V31uFEjfake2GETqZikFhx4z8hWIEf16x6NyxfiFake==", "repository_scm"=>"Xitolite", "repository"=>{"is_default"=>"1", "identifier"=>"tester", "path_encoding"=>"UTF-8", "create_readme"=>"false", "enable_git_annex"=>"false"}, "commit"=>"Create", "project_id"=>"testproj"}
  Current user: clee231 (id=7)
Redirected to http://mememe.local/redmine/projects/testproj/settings/repositories
Completed 500 Internal Server Error in 3097ms (ActiveRecord: 40.8ms)

TypeError (no implicit conversion of nil into Array):
  app/models/repository/git.rb:75:in `branches'
  app/models/repository/git.rb:130:in `fetch_changesets'

On edit action of a existing repository:

Started GET "/redmine/repositories/2/edit" for 98.226.58.246 at 2015-07-27 14:06:52 -0500
Processing by RepositoriesController#edit as HTML
  Parameters: {"id"=>"2"}
  Current user: clee231 (id=7)
  Rendered plugins/redmine_bootstrap_kit/app/views/common/_modal_base.html.haml (0.9ms)
  Rendered plugins/redmine_git_hosting/app/views/common/_git_hosting_js_headers.html.haml (9.2ms)
  Rendered plugins/redmine_git_hosting/app/views/common/_git_urls.html.haml (18.7ms)
  Rendered plugins/redmine_git_hosting/app/views/repositories/_edit_top.html.haml (33.0ms)
  Rendered repositories/_form.html.erb (7.7ms)
  Rendered plugins/redmine_git_hosting/app/views/repositories/_xitolite_options.html.haml (16.5ms)
  Rendered plugins/redmine_git_hosting/app/views/repositories/edit.html.haml within layouts/base (71.3ms)
Completed 500 Internal Server Error in 96ms (ActiveRecord: 7.3ms)

ActionView::Template::Error (no implicit conversion of nil into Array):
    35:
    36:               %p
    37:                 = label_tag 'repository_git_extra[default_branch]', l(:label_repository_default_branch)
    38:                 - if !repository.branches.empty?
    39:                   = f.select :default_branch, repository_branches_list(repository.branches)
    40:                 - else
    41:                   %span{ class: 'label label-info' }= repository.git_default_branch
  app/models/repository/git.rb:75:in `branches'

Is it worth trying to rollback redmine to a earlier version of redmine as tested by @michaelkrupp? Redmine just released version 3.1.0 on July 26, 2015.

It still is reporting errors about trying to convert nil into an array implicitly. Is it possible that something is wrong with whatever it is trying to select from the model?

I'm not too familiar with ruby development, but looking at some of the codebase, I notice {REDMINE_ROOT}/app/model/repositories.rb contains a function definition of:

def default_branch
     nil
end

Could this have anything to do with it?
I realize this is not part of the redmine_git_hosting codebase, but I'm just trying to pinpoint why/where the error occurs. Like I said, I am not too familiar with Ruby development... so I could be totally wrong. Any further insight would be helpful.

@clee231
Copy link
Author

clee231 commented Jul 29, 2015

Out of curiosity, I've tried upgrading to Redmine 3.1.0 and installed Redmine Git Hosting 1.1.1.

This error still seems to persist with the addition of a deprecation warning:

Started POST "/redmine/projects/testproj/repositories" for 98.226.58.246 at 2015-07-29 15:45:38 -0500
Processing by RepositoriesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"JmfJG8b6bp6XXXXHy/fP8PMX7QrW69FXxXxX3A7jARHfBHeUXXXXhSf2LIBz8Q08+oQ/sngvMQRu6NHXXXXX==", "repository_scm"=>"Xitolite", "repository"=>{"is_default"=>"1", "identifier"=>"tester", "path_encoding"=>"UTF-8", "create_readme"=>"false", "enable_git_annex"=>"false"}, "commit"=>"Create", "project_id"=>"testproj"}
  Current user: clee231 (id=7)
Redirected to http://mememe.local/redmine/projects/testproj/settings/repositories
DEPRECATION WARNING: Project#member_principals is deprecated and will be removed in Redmine 4.0. Use #memberships.active instead. (called from member_principals at /var/www/redmine-3.1.0/app/models/project.rb:744)
Completed 500 Internal Server Error in 2949ms (ActiveRecord: 22.8ms)

TypeError (no implicit conversion of nil into Array):
  app/models/repository/git.rb:75:in `branches'
  app/models/repository/git.rb:130:in `fetch_changesets'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Any other ideas to try?

@n-rodriguez
Copy link
Contributor

Hi! Sorry for the delay. Can you please post some logs? (from logs/git_hosting.log).
I think the bug is around here : https://github.com/jbox-web/redmine_git_hosting/blob/devel/lib/redmine/scm/adapters/xitolite_adapter.rb#L96. Maybe your Git version (1.7.1) ?

@n-rodriguez
Copy link
Contributor

Fixed in next version (1.1.3)

@n-rodriguez n-rodriguez added this to the v1.1.3 milestone Aug 26, 2015
@n-rodriguez n-rodriguez added bug and removed question labels Aug 26, 2015
@n-rodriguez
Copy link
Contributor

Actually the issue was Git 1.7.1 : 66416b0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants