Skip to content

Commit

Permalink
Release v6.25.1
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines authored Jan 5, 2023
2 parents eefe5a0 + f04d71d commit f8d6f4b
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 21 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/maze-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['1.9', '3.1']
ruby-version: ['1.9', '3.2']

uses: ./.github/workflows/run-maze-runner.yml
with:
Expand Down Expand Up @@ -36,11 +36,11 @@ jobs:
rack-version: '1'
- ruby-version: '2.2'
rack-version: '2'
- ruby-version: '3.1'
- ruby-version: '3.2'
rack-version: '2'
- ruby-version: '2.4'
rack-version: '3'
- ruby-version: '3.1'
- ruby-version: '3.2'
rack-version: '3'

uses: ./.github/workflows/run-maze-runner.yml
Expand All @@ -56,7 +56,7 @@ jobs:
include:
- ruby-version: '2.0'
que-version: '0.14'
- ruby-version: '3.1'
- ruby-version: '3.2'
que-version: '0.14'
- ruby-version: '2.5'
que-version: '1'
Expand Down Expand Up @@ -120,15 +120,15 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.7', '3.1']
ruby-version: ['2.7', '3.2']
rails-version: ['6', '7', '_integrations']
include:
- ruby-version: '2.5'
rails-version: '6'
exclude:
- ruby-version: '2.7'
rails-version: '6'
- ruby-version: '3.1'
- ruby-version: '3.2'
rails-version: '_integrations'

uses: ./.github/workflows/run-maze-runner.yml
Expand All @@ -141,7 +141,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
ruby-version: ['1.9', '2.0', '2.1', '2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']

uses: ./.github/workflows/run-maze-runner.yml
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: ['2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
ruby-version: ['2.2', '2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
optional-groups: ['test sidekiq']
include:
- ruby-version: '1.9'
Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
Changelog
=========

## v6.26.0 (1 December 2022)
## v6.25.1 (5 January 2023)

### Fixes

* Allow Gem paths to be stripped from file names in stacktraces when they contain a Regexp special character
| [#764](https://github.com/bugsnag/bugsnag-ruby/pull/764)

### Enhancements

* Use `Exception#detailed_message` instead of `Exception#message` when available
| [#761](https://github.com/bugsnag/bugsnag-ruby/pull/761)

## v6.25.0 (1 December 2022)

### Enhancements

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.25.0
6.25.1
9 changes: 9 additions & 0 deletions bugsnag.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ Gem::Specification.new do |s|
else
s.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
end

if s.respond_to?(:metadata=)
s.metadata = {
"changelog_uri" => "https://github.com/bugsnag/bugsnag-ruby/blob/HEAD/CHANGELOG.md",
"documentation_uri" => "https://docs.bugsnag.com/platforms/ruby/",
"source_code_uri" => "https://github.com/bugsnag/bugsnag-ruby/",
"rubygems_mfa_required" => "true"
}
end
end
1 change: 1 addition & 0 deletions features/fixtures/mailman/app/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'hitimes', '~> 1.2.6'
gem 'i18n', '~> 0.9.5'
gem 'rb-inotify', '0.9.8'
gem 'maildir', '~> 2.1.0'
gem 'mail', '~> 2.7.1'
gem 'activesupport', '~> 3.2'
gem 'rack', '~> 1.6.11'

Expand Down
16 changes: 9 additions & 7 deletions lib/bugsnag/middleware/suggestion_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,25 @@ def initialize(bugsnag)
@bugsnag = bugsnag
end

def call(report)
def call(event)
matches = []
report.raw_exceptions.each do |exception|
match = CAPTURE_REGEX.match(exception.message)

event.errors.each do |error|
match = CAPTURE_REGEX.match(error.error_message)

next unless match

suggestions = match.captures[0].split(DELIMITER)
matches.concat suggestions.map{ |suggestion| suggestion.strip }
matches.concat(suggestions.map(&:strip))
end

if matches.size == 1
report.add_tab(:error, {:suggestion => matches.first})
event.add_metadata(:error, { suggestion: matches.first })
elsif matches.size > 1
report.add_tab(:error, {:suggestions => matches})
event.add_metadata(:error, { suggestions: matches })
end

@bugsnag.call(report)
@bugsnag.call(event)
end
end
end
26 changes: 24 additions & 2 deletions lib/bugsnag/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,11 @@ def update_handled_counts(is_unhandled, was_unhandled)

def generate_exception_list
raw_exceptions.map do |exception|
class_name = error_class(exception)

{
errorClass: error_class(exception),
message: exception.message,
errorClass: class_name,
message: error_message(exception, class_name),
stacktrace: Stacktrace.process(exception.backtrace, configuration)
}
end
Expand All @@ -448,6 +450,26 @@ def error_class(exception)
(exception.is_a? Class) ? exception.name : exception.class.name
end

def error_message(exception, class_name)
# Ruby 3.2 added Exception#detailed_message for Gems like "Did you mean"
# to annotate an exception's message
return exception.message unless exception.respond_to?(:detailed_message)

# the "highlight" argument may add terminal escape codes to the output,
# which we don't want to include
# it _should_ always be present but it's possible to forget to add it or
# to have implemented this method before Ruby 3.2
message =
begin
exception.detailed_message(highlight: false)
rescue ArgumentError
exception.detailed_message
end

# remove the class name to be consistent with Exception#message
message.sub(" (#{class_name})", '')
end

def generate_raw_exceptions(exception)
exceptions = []

Expand Down
4 changes: 3 additions & 1 deletion lib/bugsnag/stacktrace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def self.process(backtrace, configuration)

# Strip common gem path prefixes
if defined?(Gem)
file = Gem.path.inject(file) {|line, path| line.sub(/#{path}\//, "") }
Gem.path.each do |path|
file.sub!("#{path}/", "")
end
end

trace_hash[:file] = file
Expand Down
55 changes: 54 additions & 1 deletion spec/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ def gloops
end
end

if RUBY_VERSION >= '2.0.0'
require_relative './support/exception_with_detailed_message'
else
require_relative './support/exception_with_detailed_message_ruby_1'
end

class ExceptionWithDetailedMessageButNoHighlight < Exception
def detailed_message
"detail about '#{self}'"
end
end

shared_examples "Report or Event tests" do |class_to_test|
context "metadata" do
include_examples(
Expand Down Expand Up @@ -99,6 +111,17 @@ def gloops
})
end

it "uses Exception#detailed_message if available" do
exception = ExceptionWithDetailedMessage.new("some message")
report_or_event = class_to_test.new(exception, Bugsnag.configuration)

expect(report_or_event.summary).to eq({
error_class: "ExceptionWithDetailedMessage",
message: "some message with some extra detail",
severity: "warning"
})
end

it "handles empty exceptions" do
begin
1/0
Expand Down Expand Up @@ -288,6 +311,17 @@ def gloops
)
})
end

it "uses Exception#detailed_message if available" do
exception = ExceptionWithDetailedMessage.new("some message")
report_or_event = class_to_test.new(exception, Bugsnag.configuration)

expect(report_or_event.errors.length).to eq(1)

message = report_or_event.errors.first.error_message

expect(message).to eq("some message with some extra detail")
end
end

it "has a reference to the original error" do
Expand Down Expand Up @@ -1399,7 +1433,6 @@ def gloops
end

it "does not unwrap more than 5 exceptions" do

first_ex = ex = NestedException.new("Deep exception")
10.times do |idx|
ex = ex.original_exception = NestedException.new("Deep exception #{idx}")
Expand Down Expand Up @@ -1432,6 +1465,26 @@ def gloops
}
end

it "uses Exception#detailed_message if available" do
Bugsnag.notify(ExceptionWithDetailedMessage.new("some message"))

expect(Bugsnag).to have_sent_notification{ |payload, headers|
exception = get_exception_from_payload(payload)
expect(exception["errorClass"]).to eq("ExceptionWithDetailedMessage")
expect(exception["message"]).to eq("some message with some extra detail")
}
end

it "handles implementations of Exception#detailed_message with no 'highlight' parameter" do
Bugsnag.notify(ExceptionWithDetailedMessageButNoHighlight.new("some message"))

expect(Bugsnag).to have_sent_notification{ |payload, headers|
exception = get_exception_from_payload(payload)
expect(exception["errorClass"]).to eq("ExceptionWithDetailedMessageButNoHighlight")
expect(exception["message"]).to eq("detail about 'some message'")
}
end

it "supports unix-style paths in backtraces" do
ex = BugsnagTestException.new("It crashed")
ex.set_backtrace([
Expand Down
10 changes: 10 additions & 0 deletions spec/support/exception_with_detailed_message.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ExceptionWithDetailedMessage < Exception
def detailed_message(highlight: true)
# change the output to ensure we pass the right value for "highlight"
if highlight
"\e[1m!!! #{self} !!!\e[0m"
else
"#{self} with some extra detail"
end
end
end
11 changes: 11 additions & 0 deletions spec/support/exception_with_detailed_message_ruby_1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ExceptionWithDetailedMessage for Ruby 1.9 (no keyword argument)
class ExceptionWithDetailedMessage < Exception
def detailed_message(params)
# change the output to ensure we pass the right value for "highlight"
if params[:highlight]
"\e[1m!!! #{self} !!!\e[0m"
else
"#{self} with some extra detail"
end
end
end

0 comments on commit f8d6f4b

Please sign in to comment.