From dbf45db6de97c018d55b74c9aeebf4f900599055 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Fri, 15 Jan 2016 17:14:49 +0200 Subject: [PATCH] nested_exception: fix backtrace parsing While working on https://github.com/airbrake/airbrake/pull/479 I stumbled upon a bug in Airbrake Ruby where the default filter couldn't process error payload because `:backtrace` was `nil`. Returning an empty array in case the real backtrace is missing seems to be a more secure approach. --- lib/airbrake-ruby/nested_exception.rb | 2 +- spec/{nested_exception.rb => nested_exception_spec.rb} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename spec/{nested_exception.rb => nested_exception_spec.rb} (95%) diff --git a/lib/airbrake-ruby/nested_exception.rb b/lib/airbrake-ruby/nested_exception.rb index 5d668a31..a16d4fc6 100644 --- a/lib/airbrake-ruby/nested_exception.rb +++ b/lib/airbrake-ruby/nested_exception.rb @@ -35,7 +35,7 @@ def unwind_exceptions end def parse_backtrace(exception) - return if exception.backtrace.nil? || exception.backtrace.none? + return [] if exception.backtrace.nil? || exception.backtrace.none? Backtrace.parse(exception) end end diff --git a/spec/nested_exception.rb b/spec/nested_exception_spec.rb similarity index 95% rename from spec/nested_exception.rb rename to spec/nested_exception_spec.rb index 1602ee33..05694faa 100644 --- a/spec/nested_exception.rb +++ b/spec/nested_exception_spec.rb @@ -68,8 +68,8 @@ exceptions = nested_exception.as_json expect(exceptions.size).to eq(2) - expect(exceptions[0][:backtrace]).to be_nil - expect(exceptions[1][:backtrace]).to be_nil + expect(exceptions[0][:backtrace]).to be_empty + expect(exceptions[1][:backtrace]).to be_empty end end end