Skip to content

Commit

Permalink
nested_exception: fix backtrace parsing
Browse files Browse the repository at this point in the history
While working on airbrake/airbrake#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.
  • Loading branch information
kyrylo committed Jan 18, 2016
1 parent 90f60fb commit 1c5dadf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/airbrake-ruby/nested_exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/nested_exception.rb → spec/nested_exception_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1c5dadf

Please sign in to comment.