Skip to content

Commit

Permalink
filters/keys_filter: handle hash keys that are not symbols/strings
Browse files Browse the repository at this point in the history
Fixes airbrake/airbrake#739
(Error Handler Threw An Error - Sidekiq)
  • Loading branch information
kyrylo committed May 11, 2017
1 parent b3eaf60 commit 24eb548
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/airbrake-ruby/filters/keys_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def should_filter?(_key)

def filter_hash(hash)
hash.each_key do |key|
if should_filter?(key)
if should_filter?(key.to_s)
hash[key] = FILTERED
elsif hash[key].is_a?(Hash)
filter_hash(hash[key])
Expand Down
22 changes: 22 additions & 0 deletions spec/filters/keys_blacklist_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper'

RSpec.describe Airbrake::Filters::KeysBlacklist do
subject do
described_class.new(Logger.new('/dev/null'), patterns)
end

describe "#call" do
let(:notice) do
Airbrake::Notice.new(Airbrake::Config.new, AirbrakeTestError.new)
end

context "when a pattern is a regexp and when a key is a hash" do
let(:patterns) { [/bango/] }

it "doesn't fail" do
notice[:params] = { bingo: { {} => 'unfiltered' } }
expect { subject.call(notice) }.not_to raise_error
end
end
end
end

0 comments on commit 24eb548

Please sign in to comment.