Project

General

Profile

Actions

Defect #33195

closed

500 error when having only one SCM enabled

Added by Txinto Vaz over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
SCM
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

Look at this code

 def build_new_repository_from_params
    print params
    print ("\n-------------\n")
    print params[:repository_scm]
    print ("\n-------2-----\n")
    print Redmine::Scm::Base.all
    print ("\n-------3-----\n")
    print Setting.enabled_scm
    print ("\n-------4-----\n")
    print (Redmine::Scm::Base.all & Setting.enabled_scm)
    print ("\n-------5-----\n")
    print (Redmine::Scm::Base.all & Setting.enabled_scm).first
    print ("\n-------6-----\n")
    scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
    unless @repository = Repository.factory(scm)
      render_404
      return
    end

    @repository.project = @project
    @repository.safe_attributes = params[:repository]
    @repository
  end

And look at these two traces:

  • The first one when you only have Git enabled as SCM (fails)
  • The second one when you have Git and Bazaar enabled (works)
App 3169 output: lib/redmine/sudo_mode.rb:65:in `sudo_mode'
App 3169 output: I, [2020-03-24T19:56:15.246929 #3169]  INFO -- : Started GET "/projects/demo/repositories/new" for 95.16.232.60 at 2020-03-24 19:56:15 +0000
App 3169 output: I, [2020-03-24T19:56:15.248246 #3169]  INFO -- : Processing by RepositoriesController#new as */*
App 3169 output: I, [2020-03-24T19:56:15.248387 #3169]  INFO -- :   Parameters: {"project_id"=>"demo"}
App 3169 output: I, [2020-03-24T19:56:15.259065 #3169]  INFO -- :   Current user: admin (id=1)
App 3169 output: {"controller"=>"repositories", "action"=>"new", "project_id"=>"demo"}
App 3169 output:
App 3169 output: -------------
App 3169 output:
App 3169 output: -------2-----
App 3169 output: ["Subversion", "Mercurial", "Cvs", "Bazaar", "Git", "Filesystem"]
App 3169 output:
App 3169 output: -------3-----
App 3169 output: ---
App 3169 output: - Git
App 3169 output:
App 3169 output: -------4-----
App 3169 output: I, [2020-03-24T19:56:15.260911 #3169]  INFO -- : Completed 500 Internal Server Error in 12ms (ActiveRecord: 6.9ms)
App 3169 output: F, [2020-03-24T19:56:15.294974 #3169] FATAL -- :
App 3169 output: F, [2020-03-24T19:56:15.295096 #3169] FATAL -- : TypeError (no implicit conversion of String into Array):
App 3169 output: F, [2020-03-24T19:56:15.295120 #3169] FATAL -- :
App 3169 output: F, [2020-03-24T19:56:15.295142 #3169] FATAL -- : app/controllers/repositories_controller.rb:300:in `&'
App 3169 output: app/controllers/repositories_controller.rb:300:in `build_new_repository_from_params'
App 3169 output: lib/redmine/sudo_mode.rb:65:in `sudo_mode'

App 3169 output: I, [2020-03-24T19:56:46.663214 #3169]  INFO -- : Started GET "/projects/demo/repositories/new" for 95.16.232.60 at 2020-03-24 19:56:46 +0000
App 3169 output: I, [2020-03-24T19:56:46.664097 #3169]  INFO -- : Processing by RepositoriesController#new as HTML
App 3169 output: I, [2020-03-24T19:56:46.664179 #3169]  INFO -- :   Parameters: {"project_id"=>"demo"}
App 3169 output: I, [2020-03-24T19:56:46.672322 #3169]  INFO -- :   Current user: admin (id=1)
App 3169 output: {"controller"=>"repositories", "action"=>"new", "project_id"=>"demo"}
App 3169 output:
App 3169 output: -------------
App 3169 output:
App 3169 output: -------2-----
App 3169 output: ["Subversion", "Mercurial", "Cvs", "Bazaar", "Git", "Filesystem"]
App 3169 output:
App 3169 output: -------3-----
App 3169 output: ["Bazaar", "Git"]
App 3169 output:
App 3169 output: -------4-----
App 3169 output: ["Bazaar", "Git"]
App 3169 output:
App 3169 output: -------5-----
App 3169 output: Bazaar
App 3169 output:
App 3169 output: -------6-----
App 3169 output: I, [2020-03-24T19:56:46.698968 #3169]  INFO -- :   Rendering repositories/new.html.erb within layouts/base
App 3169 output: I, [2020-03-24T19:56:46.704682 #3169]  INFO -- :   Rendered repositories/_form.html.erb (3.1ms)
App 3169 output: I, [2020-03-24T19:56:46.705038 #3169]  INFO -- :   Rendered repositories/new.html.erb within layouts/base (5.9ms)
App 3169 output: I, [2020-03-24T19:56:46.708987 #3169]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_html_head.html.slim (1.0ms)
App 3169 output: I, [2020-03-24T19:56:46.709287 #3169]  INFO -- :   Rendering plugins/wiki_graphviz_plugin/app/views/wiki_graphviz/_head.html.erb
App 3169 output: I, [2020-03-24T19:56:46.709553 #3169]  INFO -- :   Rendered plugins/wiki_graphviz_plugin/app/views/wiki_graphviz/_head.html.erb (0.2ms)
App 3169 output: I, [2020-03-24T19:56:46.709938 #3169]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_body_top.slim (0.1ms)
App 3169 output: I, [2020-03-24T19:56:46.724633 #3169]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_content.html.slim (0.2ms)
App 3169 output: I, [2020-03-24T19:56:46.725207 #3169]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_body_bottom.html.slim (0.3ms)
App 3169 output: I, [2020-03-24T19:56:46.725593 #3169]  INFO -- : Completed 200 OK in 61ms (Views: 22.5ms | ActiveRecord: 13.3ms)

Possible root cause: when you have only one SCM enabled, the result of the & operation is a String, not an array. This is causing it to fail.

A workaround is to enable another SCM.

Regards.

Actions #1

Updated by Go MAEDA over 4 years ago

I was unable to reproduce the error. If you use plugins, could you try again after removing all plugins?

{"controller"=>"repositories", "action"=>"new", "project_id"=>"ecookbook"}
-------------

-------2-----
["Subversion", "Mercurial", "Cvs", "Bazaar", "Git", "Filesystem"]
-------3-----
["Git"]
-------4-----
["Git"]
-------5-----
Git
-------6-----
Actions #2

Updated by Txinto Vaz over 4 years ago

You are right.
If I uncheck Git and check it again, the trace is this:

App 4118 output: 
App 4118 output: -------------
App 4118 output: 
App 4118 output: -------2-----
App 4118 output: ["Subversion", "Mercurial", "Cvs", "Bazaar", "Git", "Filesystem"]
App 4118 output: 
App 4118 output: -------3-----
App 4118 output: ["Git"]
App 4118 output: 
App 4118 output: -------4-----
App 4118 output: ["Git"]
App 4118 output: 
App 4118 output: -------5-----
App 4118 output: Git
App 4118 output: 
App 4118 output: -------6-----
pp 4118 output: I, [2020-03-25T22:59:36.958429 #4118]  INFO -- :   Rendering repositories/new.html.erb within layouts/base
App 4118 output: I, [2020-03-25T22:59:36.962682 #4118]  INFO -- :   Rendered repositories/_form.html.erb (3.2ms)
App 4118 output: I, [2020-03-25T22:59:36.963035 #4118]  INFO -- :   Rendered repositories/new.html.erb within layouts/base (4.5ms)
App 4118 output: I, [2020-03-25T22:59:36.967955 #4118]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_html_head.html.slim (1.5ms)
App 4118 output: I, [2020-03-25T22:59:36.968282 #4118]  INFO -- :   Rendering plugins/wiki_graphviz_plugin/app/views/wiki_graphviz/_head.html.erb
App 4118 output: I, [2020-03-25T22:59:36.968779 #4118]  INFO -- :   Rendered plugins/wiki_graphviz_plugin/app/views/wiki_graphviz/_head.html.erb (0.4ms)
App 4118 output: I, [2020-03-25T22:59:36.969519 #4118]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_body_top.slim (0.3ms)
App 4118 output: I, [2020-03-25T22:59:36.986247 #4118]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_content.html.slim (0.4ms)
App 4118 output: I, [2020-03-25T22:59:36.986930 #4118]  INFO -- :   Rendered plugins/additionals/app/views/additionals/_body_bottom.html.slim (0.4ms)
App 4118 output: I, [2020-03-25T22:59:36.987272 #4118]  INFO -- : Completed 200 OK in 46ms (Views: 24.2ms | ActiveRecord: 12.3ms)

The reason was a plugin I was developing which tried to preconfigure Redmine for an automatic installation based in docker.
In my code I have this:

     s = Setting.find_by_name("enabled_scm")
     if (s == nil) then
       s = Setting.new
       s.name="enabled_scm" 
     end
     s.value = "Git" 
     s.save

and I think I have to change it to this:

     s = Setting.find_by_name("enabled_scm")
     if (s == nil) then
       s = Setting.new
       s.name="enabled_scm" 
     end
     s.value = ["Git"]
     s.save

Thank you for your support, sorry for the noise.
Regards.

Actions #3

Updated by Txinto Vaz over 4 years ago

  • Status changed from New to Resolved
Actions #4

Updated by Go MAEDA over 4 years ago

  • Status changed from Resolved to Closed
  • Resolution set to Invalid

Thank you for the feedback and I am happy to know that the issue on your instance is resolved.

Actions

Also available in: Atom PDF