Note that there are some explanatory texts on larger screens.

plurals
  1. PORails: ParameterFilter::compiled_filter tries to dup symbol
    primarykey
    data
    text
    <p>I'm running rails3 with rails exception-notifier gem. When an exception occurs, and an email should be sent, I'm getting an exception from the ParameterFilter class. I've found the problem in the rails source, and am not sure the best way to proceed.</p> <p>The problem occurs in ActionDispatch::Http::ParameterFilter. In the compiled_filter method, an error occurs on line 38: <code>key = key.dup</code> when <code>key</code> is a symbol, because symbols are not duplicable. Here is the source:</p> <pre><code>def compiled_filter ... elsif blocks.present? key = key.dup value = value.dup if value.duplicable? blocks.each { |b| b.call(key, value) } end </code></pre> <p>I see that they only call <code>dup</code> on <code>value</code> when it is <code>duplicable</code>. If I patch the source to only call <code>dup</code> on <code>key</code> when <code>key</code> is <code>duplicable</code>, then my problem goes away. I'm assuming there is a reason why the author put that condition on <code>value</code> and not <code>key</code>, so I'm curious if someone out there has a better understanding of this code.</p> <p>This error only occurs when you add a block to your filter params in application.rb. So, maybe there is a workaround for my original issue that does not require using a block here. If you're interested see my coworker's question <a href="https://stackoverflow.com/questions/5265747/rails-filter-sensitive-data-in-json-parameter-from-logs">Rails: Filter sensitive data in JSON parameter from logs</a> </p> <p>The key for which this is a problem is <code>:action</code>. This comes from rails and I don't know if there is any way to force it to be a string instead.</p> <p>I filed a rails bug <a href="https://rails.lighthouseapp.com/projects/8994/tickets/6557-symbol-duplication-error-in-parameterfilter-compiled_filter" rel="nofollow noreferrer">https://rails.lighthouseapp.com/projects/8994/tickets/6557-symbol-duplication-error-in-parameterfilter-compiled_filter</a> and I have a patch ready that adds if <code>key.duplicable?</code> to the <code>key.dup</code> line, I'm looking for input on whether or not that is the right solution.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload