# Bug in dispatcher.rb?

**URL:** <https://www.ruby-forum.com/t/bug-in-dispatcher-rb/138307>\
**Category:** Rails\
**Created:** [May 21, 2008, 10:19pm UTC](https://www.ruby-forum.com/t/bug-in-dispatcher-rb/138307 "2008-05-21T22:19:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 21, 2008, 10:19pm UTC](https://www.ruby-forum.com/t/bug-in-dispatcher-rb/138307/1 "2008-05-21T22:19:25Z")

</div>

I’m developing my app against Ror 2.0, and I noticed my public/  
500.html page was not rendered in response to some low level errors  
(like when I stopped MySql). So I did some debugging to figure out  
why. After some digging I think I’m seeing a bug in the way  
dispatcher.rb looks for the error pages.

This seems incredible to me. How could such a basic bug not be  
detected?

But the code I’m looking at sure looks wrong. The filename it  
constructs for the 500.html page has an extra space in it: “public/  
500 .html”

Here’s my diff:

# C:\projects[…]\vendor\rails\>svn diff . Index: actionpack/lib/action\_controller/dispatcher.rb

— actionpack/lib/action\_controller/dispatcher.rb (revision  
9641)  
+++ actionpack/lib/action\_controller/dispatcher.rb (working copy)  
@@ -61,7 +61,7 @@

```
   private
     def failsafe_response_body(status)

```

- 

```
     error_path = "#{error_file_path}/#{status.to_s[0..3]}.html"

```

- 

```
     error_path = "#{error_file_path}/#{status}.html"

     if File.exist?(error_path)
       File.read(error_path)

```

I’ve tested this on WinXP and OS X with the same results. I tried  
searching this group and the lighthouse bug db, but I see no other  
references to this problem… I did find a 9-month old Trac ticket  
reporting this problem, but the old Trac system is obsolete, right?  
([http://dev.rubyonrails.org/ticket/9305](http://dev.rubyonrails.org/ticket/9305)) What am I missing?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 22, 2008, 2:32am UTC](https://www.ruby-forum.com/t/bug-in-dispatcher-rb/138307/2 "2008-05-22T02:32:08Z")

</div>

I wasn’t aware ANY request went through dispatcher.rb.

Correct me if I’m wrong.

On Thu, May 22, 2008 at 5:43 AM, KC [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> But the code I’m looking at sure looks wrong. The filename it  
> +++ actionpack/lib/action\_controller/dispatcher.rb (working copy)  
> I’ve tested this on WinXP and OS X with the same results. I tried  
> searching this group and the lighthouse bug db, but I see no other  
> references to this problem… I did find a 9-month old Trac ticket  
> reporting this problem, but the old Trac system is obsolete, right?  
> ([http://dev.rubyonrails.org/ticket/9305](http://dev.rubyonrails.org/ticket/9305)) What am I missing?
> 
> >

–  
Appreciated my help?  
Recommend me on Working With Rails  
[http://workingwithrails.com/person/11030-ryan-bigg](http://workingwithrails.com/person/11030-ryan-bigg)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 22, 2008, 8:11am UTC](https://www.ruby-forum.com/t/bug-in-dispatcher-rb/138307/3 "2008-05-22T08:11:26Z")

</div>

@KC – Are you seeing this in _production_? Seems more likely that  
it’s a development issue (ie., all requests considered local via your /  
environment/development.rb) so that you see the error page that helps  
you debug. I see a page with backtrace in dev (WinXP and Ubuntu) but  
the expected 500 page if an error occurs in production.

On May 21, 8:31 pm, “Ryan B. (Radar)” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 22, 2008, 6:53pm UTC](https://www.ruby-forum.com/t/bug-in-dispatcher-rb/138307/4 "2008-05-22T18:53:39Z")

</div>

All my testing has been in development instances. I’ll try production  
now. Makes sense that the routing would be different in the  
production environment.

But the code in question is in need or repair. It attempts to show  
the 500 or 404 page and fails due to the string formatting error.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [May 22, 2008, 6:55pm UTC](https://www.ruby-forum.com/t/bug-in-dispatcher-rb/138307/5 "2008-05-22T18:55:25Z")

</div>

I can verify that this code is called in at least one context: when I  
shut down my MySql server and attempted a request that involved active  
record. No idea if this is

On May 21, 5:31 pm, “Ryan B. (Radar)” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
