kubitron / redmine_git_hosting

A ChiliProject/Redmine plugin which makes configuring your own git hosting easy.
78 stars 15 forks source link

Error with RepositoryMirrorsController#create #41

Closed phindmarsh closed 12 years ago

phindmarsh commented 12 years ago

When trying to configure a repository mirror on the Settings > Repository page I get the following error:

Processing RepositoryMirrorsController#create (for 10.0.0.202 at 2012-04-05 14:12:42) [GET]
  Parameters: {"project_id"=>"cognise", "action"=>"create", "controller"=>"repository_mirrors"}
Rendering template within layouts/popup
Rendering repository_mirrors/create

ActionView::TemplateError (undefined method `html_safe' for #<String:0xb55c60d8>) on line #7 of vendor/plugins/redmine_git_hosting/app/views/layouts/popup.erb:
4: <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5: <meta name="description" content="<%= Redmine::Info.app_name %>" />
6: <meta name="keywords" content="issue,bug,tracker" />
7: <%= csrf_meta_tag %>
8: <%= favicon %>
9: <%= stylesheet_link_tag 'application', :media => 'all' %>
10: <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>

// big stack trace follows....

I have Redmine 1.1.2.stable installed via apt-get on Debian 6.0.4 with 0.4.4x of the Redmine Git Hosting plugin (which I did a pull of just the other day).

phindmarsh commented 12 years ago

To clarify, this has worked in the past, and repositories that have the mirrors already configured continue to mirror their contents on push as expected.

Thanks for your help! :)

phindmarsh commented 12 years ago

Actually, turns out its a Debian regression not a plugin issue.

Should probably Google before filing a bug report :)

phindmarsh commented 12 years ago

Actually, I'm not completely capable of understanding the ticket, but it seems like the function has been removed or something?

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=629067

Is this still something that needs to be looked into?

kubitron commented 12 years ago

Well, the problem seems to be a Redmine/ruby-on-rails problem, I believe, not necessarily a plugin problem. The failure happens on a "csrf_meta_tag", which is a ruby-on-rails tag to prevent cross-scripting attacks. Very weird. I'm not sure why html_safe is not working (or alternatively, why csrf_meta_tag is defined but fails).

phindmarsh commented 12 years ago

Ok sweet, no problems. I'll see if there are any patches for it. Cheers!

kubitron commented 12 years ago

Well, before you go away, there are a couple of weird things... (1) seems like Redmine doesn't use csrf_meta_tag for version 1.1, not sure why. Perhaps I need some sort of patch to avoid this problem... (2) on the flip side, csrf_meta_tag is clearly defined, otherwise the error would be different. Since this is a ruby-on-rails function, there must be something inconsistent with the debian release you have, but (3) I know of at least 1 person who has this plugin working with Redmine 1.1.

Can you tell me what versions of Rails you are using? (Or, better, simply do:

./script/about RAILS_ENV=production

I'm curious what version of ActionPack you are using.

phindmarsh commented 12 years ago

Heres the output of that command:

/usr/share/redmine/lib/redmine/scm/adapters/git_adapter.rb:25: warning: already initialized constant GIT_BIN
/usr/share/redmine/vendor/plugins/redmine_git_hosting/lib/git_hosting/patches/git_adapter_patch.rb:27: warning: already initialized constant GIT_BIN
About your application's environment
Ruby version              1.8.7 (i486-linux)
RubyGems version          1.3.7
Rack version              1.1
Rails version             2.3.5
Active Record version     2.3.5
Active Resource version   2.3.5
Action Mailer version     2.3.5
Active Support version    2.3.5
Edge Rails revision       unknown
Application root          /usr/share/redmine
Environment               development
Database adapter          mysql
Database schema version   20120226013750

About your Redmine plugins
Redmine Time Tracker plugin   0.4
Redmine Git Hosting Plugin    0.4.4x

Its likely there is a misconfiguration, I don't know if I have all the dependencies satisfied correctly, the debian package is pretty old but I don't want to have to manage it manually (apt-get is just too easy :))

kubitron commented 12 years ago

Hm... Not sure I can help here -- except that I could try to figure out how to remove the cross-scripting protection when html_safe is undefined. However, it seems like a weird inconsistency. Perhaps this is a debian problem...?

Haven't you been using this plugin successfully in other configurations prior to this? Is it possible that I broke something with the 0.4.4x release? (seems unlikely, since I have never touched the popup.erb file).

phindmarsh commented 12 years ago

Thinking about it I don't think I have ever tried with the instance we have on Debian now (previously Ubuntu). I'm almost certain its not a fault of the plugin given the googling I have done in the last few hours. I just jumped the gun with the bug report :)

kubitron commented 12 years ago

Well -- interestingly enough, Redmine 1.1 doesn't seem to use the csrf_meta_tag (used in later versions), so perhaps this problem doesn't manifest normally for Redmine.... If it turns out that this is the best Debian release available, I can fix this particular problem.

kubitron commented 12 years ago

Ok. I am assuming that this is the latest versions of Rails (including security patches) for the particular version of Debian you are using? If so, you are likely not the only person who will run into this problem.

Why don't you try pulling my testing branch. What I did was put in code to allow the csrf_meta_tag to fail gracefully if you have an installation with version skew in the Rails implementation (which seems to be what you are getting with Debian at the moment). See if it fixes things. If so, I'll make the commit.

phindmarsh commented 12 years ago

Ok, I've pulled that down and now I get a different missing function!

'javascript_heads' on line 11 of prompt.erb

I don't know if I have the latest versions of rails etc installed, it's just whatever a default install using debian spits out. Is there something I can use to check the versions I am using to confirm for you? Sorry I'm not very up to speed with rails :)

kubitron commented 12 years ago

Um.... I don't see any "prompt.erb" either in the plugin or redmine. Is this from some other plugin?

What was the full error message (as in what you started this thread with)?

phindmarsh commented 12 years ago

Argh sorry! I was on my phone when I replied to that. Supposed to be popup.erb, full trace below:

Processing RepositoryMirrorsController#create (for 121.73.152.215 at 2012-04-09 17:12:09) [GET]
  Parameters: {"project_id"=>"cognise", "action"=>"create", "controller"=>"repository_mirrors"}
Rendering template within layouts/popup
Rendering repository_mirrors/create

ActionView::TemplateError (undefined local variable or method `javascript_heads' for #<ActionView::Base:0xb5513f3c>) on line #11 of vendor/plugins/redmine_git_hosting/app/views/layouts/popup.erb:
8: <%= favicon %>
9: <%= stylesheet_link_tag 'application', :media => 'all' %>
10: <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
11: <%= javascript_heads %>
12: <%= heads_for_theme %>
13: <!--[if IE 6]>
14: <style type="text/css">

Edit: clicked the wrong button, didn't mean to close it again. :S

kubitron commented 12 years ago

Hm.... Ok. You have uncovered a slight flaw in my Redmine 1.1 support. Guess my previous Redmine 1.1 user missed the mirror support (as did I).

I'll fix this when I get a chance (probably later today).

phindmarsh commented 12 years ago

Not a problem, this isn't a show-stopper for us really but if you have the time it would be great :)

thanks!

kubitron commented 12 years ago

Ok. Kill off your current testing branch and re-pull testing...

(Easiest thing is to do a:

git reset --hard HEAD^

and pull the testing branch again).

phindmarsh commented 12 years ago

Thats fixed it, I created a new mirror and pushed to it successfully. Problem solved, thanks!

kubitron commented 12 years ago

Ok. Going to close this issue and push fix to master.