From 4702c9329ae9e0695e45d7b028cacc70c3e432a1 Mon Sep 17 00:00:00 2001 From: Yohei Kitamura Date: Tue, 9 May 2023 11:48:21 -0400 Subject: [PATCH] Fix Lorekeeper::BacktraceCleaner#clean to not raise when a non-array value is passed (#38) --- CHANGELOG.md | 3 +++ lib/lorekeeper/backtrace_cleaner.rb | 2 ++ lib/lorekeeper/version.rb | 2 +- spec/lib/lorekeeper/backtrace_cleaner_spec.rb | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10b2f28..ba59c9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.6.1 +* Fix Lorekeeper::BacktraceCleaner#clean to not raise when a non-array value is passed + # 2.6.0 * Expose Lorekeeper::BacktraceCleaner diff --git a/lib/lorekeeper/backtrace_cleaner.rb b/lib/lorekeeper/backtrace_cleaner.rb index e892341..e9fd029 100644 --- a/lib/lorekeeper/backtrace_cleaner.rb +++ b/lib/lorekeeper/backtrace_cleaner.rb @@ -15,6 +15,8 @@ def initialize end def clean(backtrace) + return [] unless backtrace.is_a?(Array) + backtrace = filter_rails_root_backtrace(backtrace) @backtrace_cleaner&.clean(backtrace) || backtrace end diff --git a/lib/lorekeeper/version.rb b/lib/lorekeeper/version.rb index 2e37213..338243f 100644 --- a/lib/lorekeeper/version.rb +++ b/lib/lorekeeper/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Lorekeeper - VERSION = '2.6.0' + VERSION = '2.6.1' end diff --git a/spec/lib/lorekeeper/backtrace_cleaner_spec.rb b/spec/lib/lorekeeper/backtrace_cleaner_spec.rb index d7faa2d..c884adc 100644 --- a/spec/lib/lorekeeper/backtrace_cleaner_spec.rb +++ b/spec/lib/lorekeeper/backtrace_cleaner_spec.rb @@ -100,6 +100,10 @@ ]) end + it 'returns an empty array when nil is passed' do + expect(instance.clean(nil)).to eq([]) + end + context 'with LOREKEEPER_DENYLIST env var' do before do allow(ENV).to receive(:key?).with('LOREKEEPER_DENYLIST').and_return(true)