Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

rake routes messed up with Sinatra apps #496

Closed
ericmnel opened this Issue · 7 comments

3 participants

@ericmnel

Hey - most likely I am just doing something wrong, but here is what I am seeing:

I have two sinatra apps (sinatra v 1.3.2) in my routes.rb file:

JsonServer::Application.routes.draw do

root :to => 'pages#index'

mount Resque::Server.new, :at => "/resque"
mount MongodbLogger::Server.new, :at => "/mongo"

...

And everything seems to work, but I get exceptions when I do a 'rake routes'.

                   root        /                                              pages#index
                                /resque                                        #<Sinatra::ShowExceptions:0x0000000600f798 @app=#<Rack::Head:0x0000000600f7c0...
                               /mongo                                         #<Sinatra::ShowExceptions:0x00000006028a90 @app=#<Rack::Head:0x00000006028ab8 @app=#<Rack::NullLogger:0x00000006028ae0 @app=#<Rack::Protection::FrameOptions:0x00000006028ba8 @app=#<Rack::Protection::IPSpoofing:0x00000006028c20 @app=#<Rack::Protection::JsonCsrf:0x00000006028c98 @app=#<Rack::Protection::PathTraversal:0x00000006028d10 
@rkh
Owner

What is the exception? The output seems legit to me, except that the inspect is super ugly.

@ericmnel

It looks like it is a "Forbidden" exception from Rack::Protection, maybe because I have a password set in my initializers -

MongodbLogger::Server.use Rack::Auth::Basic do |username, password|
username = 'blah'
password = 'blahblah'
end

Here is a bigger hunk of the traceback:

Sinatra::ShowExceptions:0x0000000600f798 @app=#>, @realm=nil, @authenticator=#Proc:0x0000000521c848@/jigsaw/jsonServer/current/config/initializers/resque.rb:6>, @options={:reaction=>:default_reaction, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :xss_mode=>:block, :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:default_reaction, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:default_reaction, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:default_reaction, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:default_reaction, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :xss_mode=>:block, :frame_options=>:sameorigin, :except=>[:session_hijacking, :remote_token]}>>>, @template=#\n\n\n \n \"\n\n\n\n; _erbout.concat((h exception.class ).to_s); _erbout.concat \" at \"; _erbout.concat((h path ).to_s); _erbout.concat \"\n\n \n\n\n * {margin: 0; padding: 0; border: 0; outline: 0;}\n div.clear {clear: both;}\n body {background: #EEEEEE; margin: 0; padding: 0;\n font-family: &#39;Lucida Grande&#39;, &#39;Lucida Sans Unicode&#39;,\n &#39;Garuda&#39;;}\n code {font-family: &#39;Lucida Console&#39;, monospace;\n font-size: 12px;}\n li {height: 18px;}\n ul {list-style: none; margin: 0; padding: 0;}\n ol:hover {cursor: pointer;}\n ol li {white-space: pre;}\n #explanation {font-size: 12px; color: #666666;\n margin: 20px 0 0 100px;}\n/* WRAP <em>/\n #wrap {width: 1000px; background: #FFFFFF; margin: 0 auto;\n padding: 30px 50px 20px 50px;\n border-left: 1px solid #DDDDDD;\n border-right: 1px solid #DDDDDD;}\n/</em> HEADER <em>/\n #header {margin: 0 auto 25px auto;}\n #header img {float: left;}\n #header #summary {float: left; margin: 12px 0 0 20px; width:660px;\n font-family: &#39;Lucida Grande&#39;, &#39;Lucida Sans Unicode&#39;;}\n h1 {margin: 0; font-size: 36px; color: #981919;}\n h2 {margin: 0; font-size: 22px; color: #333333;}\n #header ul {margin: 0; font-size: 12px; color: #666666;}\n #header ul li strong{color: #444444;}\n #header ul li {display: inline; padding: 0 10px;}\n #header ul li.first {padding-left: 0;}\n #header ul li.last {border: 0; padding-right: 0;}\n/</em> BODY <em>/\n #backtrace,\n #get,\n #post,\n #cookies,\n #rack {width: 980px; margin: 0 auto 10px auto;}\n p#nav {float: right; font-size: 14px;}\n/</em> BACKTRACE */\n a#expando {float: left; padding-left: 5px; color: #666666;\n font-size: 14px; text-decoration: none; cursor: pointer;}\n a#expando:hover {text-decoration: underline;}\n h3 {float: left; width: 100px; margin-bottom: 10px;\n color: #981919; font-size: 14px; font-weight: bold;}\n #nav a {color: #666666; text-decoration: none; padding: 0 5px;}\n #backtrace li.frame-info {background: #f7f7f7; padding-left: 10px;\n font-size: 12px; color: #333333;}\n #backtrace ul {list-style-position: outside; border: 1px solid #E9E9E9;\n border-bottom: 0;}\n #backtrace ol {width: 920px; margin-left: 50px;\n font: 10px &#39;Lucida Console&#39;, monospace; color: #666666;}\n #backtrace ol li {border: 0; border-left: 1px solid #E9E9E9;\n padding: 2px 0;}\n #backtrace ol code {font-size: 10px; color: #555555; padding-left: 5px;}\n #backtrace-ul li {border-bottom: 1px solid #E9E9E9; height: auto;\n</p>

@rkh
Owner

Sinatra::ShowExceptions is not an exception, it's a Rack middleware and mounted at /resque.

@ericmnel

Ah - I think I understand now. The 'rake routes' command is not triggering an exception, it is just doing an inspect on what is bound in to the route point (which happens to be the Sinatra show exceptions object).

So it is probably a bug in rake routes, doing an inspect does not seem like the right thing to show in response to a mount/at entry in the routes.rb file.

@rkh
Owner

What else is it supposed to do? It might be able to check if the inspect string is rather long and shorten it. I have been toying with the idea of adding a dummy middleware in front that also gives easy access to the actual Sinatra application object. It could implement a saner inspect.

@ericmnel

Well, IMHO the most intuitive behavior would be to print out the name of the Sinatra subclass, if that is possible, like this:

JsonServer::Application.routes.draw do
root :to => 'pages#index'
mount Resque::Server.new, :at => "/resque"
mount MongodbLogger::Server.new, :at => "/mongo"
}

would result in something like:

                   root        /                                              pages#index
                                 /resque                                   Resque::Server    
                                 /mongo                                   MongodbLogger::Server     
@rkh rkh closed this in f9b1c60
@kostia kostia referenced this issue in kostia/riddick
Closed

Rake routes shows ugly struct Sinatra #5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.