Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception Notification Missing rack.input

When I am trying to use Exception Notification plugin in my Rails 3 project, I am getting this error.

Missing rack.input

this error is occurring in

/vendor/plugins/exception_notification/lib/exception_notifier/views/exception_notifier/_request.text.erb
at line 3

This is the _request.text.erb file

1: * URL       : <%= raw @request.url %>
2: * IP address: <%= raw @request.remote_ip %>
3: * Parameters: <%= raw @request.filtered_parameters.inspect %>
4: * Rails root: <%= raw Rails.root %>

I have not over ridden this anywhere in my app. please help. Stuck here in this error for one full day

like image 977
Anand Avatar asked Oct 10 '10 15:10

Anand


2 Answers

I know this is an old question. But in case it helps someone seeing this. I was seeing the "Missing rack.input" error recently when communicating with an internal API. One of the thing we were attempting to do was to respond with only the minimal http headers by doing something like this:

def set_env_data
  env = request.env.to_hash
  env.delete_if { |k, v| k == k.downcase }
  @sample_model.env = env
end

We wanted to strip out the headers set by the framework. Although our communication was working we'd see "Missing rack.input" in the stack trace. In this specific case it was because we were missing the request_id set by action_dispatch. So we changed:

env.delete_if { |k, v| k == k.downcase }

To:

env.delete_if { |k, v| k == k.downcase && !k.starts_with?('rack') && !k.starts_with?('action_dispatch') }

Ultimately I think that since now we're only deleting a few headers that we may as well send everything back. If you encounter an error inside the framework it can be tough to debug. I would start by looking for places where you might be altering how the framework prefers to communicate. Hopefully someone finds this useful.

like image 21
toddmetheny Avatar answered Sep 24 '22 22:09

toddmetheny


This error can occur when there's something wrong with the env hash.

I got the "Missing rack.input" error today. I was trying to force ExceptionNotifier to send the email inside a rescue block, and then have my application recover normally. But I had accidentally written:

ExceptionNotifier::Notifier.exception_notification(Rails.env, e).deliver

When it should be:

ExceptionNotifier::Notifier.exception_notification(request.env, e).deliver

That is, I was sending Rails.env, which is just a string, instead of request.env, the hash that includes the rack.input object.

Hope this helps anyone with similar rack.input problems.

like image 163
Michael Keenan Avatar answered Sep 24 '22 22:09

Michael Keenan