Skip to content

Commit

Permalink
Merge branch 'master' into cawllec/auto_at_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Cawllec committed Apr 25, 2018
2 parents ef71903 + 2a61e9b commit dc27a28
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 34 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Changelog
=========

## 6.7.2 (24 Apr 2018)

### Fixes

* (Notify) Handle `notify` calls with `nil` arguments correctly
| [#439](https://github.com/bugsnag/bugsnag-ruby/pull/439)

## 6.7.1 (11 Apr 2018)

### Fixes

* (Rails) Log missing key warning after initialization completes, avoiding
incorrectly logging a warning that the API key is missing
| [#444](https://github.com/bugsnag/bugsnag-ruby/pull/444)

## 6.7.0 (05 Apr 2018)

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.7.0
6.7.2
2 changes: 1 addition & 1 deletion bugsnag.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Gem::Specification.new do |s|

s.description = "Ruby notifier for bugsnag.com"
s.summary = "Ruby notifier for bugsnag.com"
s.homepage = "http://github.com/bugsnag/bugsnag-ruby"
s.homepage = "https://github.com/bugsnag/bugsnag-ruby"
s.licenses = ["MIT"]

s.files = `git ls-files`.split("\n").reject {|file| file.start_with? "example/"}
Expand Down
56 changes: 43 additions & 13 deletions issue_template.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
### Expected behavior
*[Insert details on expected behaviour]*
### Description
<!-- A quick description of what you're trying to accomplish -->

### Observed behavior
*[Insert details on observed behaviour]*
### Issue
<!--
What went wrong? (If this issue is a general question or a proposed change,
feel free to delete this and subsequent sections.
-->

### Steps to reproduce
*[Insert reproduction steps (if known)]*
### Environment

### Version
*[Insert version information]*
Library versions:

### Additional information
*[Insert any additional information]*
<!--
Paste the output of this command into the code block below:
bundle list | grep -E "(bugsnag|rails|sidekiq|que|sinatra|resque|shoryuken|mailman|delayed_job)"
-->
```
#### Can't comment on Issues?
Some users have been unable to comment on Github issues when an [adblocker extension is enabled](https://docs.bugsnag.com/platforms/browsers/faq/#is-bugsnag-blocked-by-ad-blockers).
We recommend temporarily disabling the extension, or if that fails, contacting support@bugsnag.com.
```

- OS / OS version:
- debug mode or production?:

<!--
Below are a few approaches you might take to communicate the issue, in
descending order of awesomeness. Please choose one and feel free to delete
the others from this template.
-->
### Example Repo

- [ ] Create a minimal repository that can reproduce the issue after running
`bundle install` and `rackup` (or `rails server`, or `ruby some-script.rb`,
etc)
- [ ] Link to it here:

### Example code snippet

```ruby
require 'bugsnag'

# (Insert code sample to reproduce the problem)
```

<!-- Error messages, if any -->
```
```
42 changes: 24 additions & 18 deletions lib/bugsnag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module Bugsnag
LOCK = Mutex.new
INTEGRATIONS = [:resque, :sidekiq, :mailman, :delayed_job, :shoryuken, :que]

NIL_EXCEPTION_DESCRIPTION = "'nil' was notified as an exception"

class << self
##
# Configure the Bugsnag notifier application-wide settings.
Expand All @@ -55,25 +57,9 @@ def notify(exception, auto_notify=false, &block)
auto_notify = false
end

if !configuration.auto_notify && auto_notify
configuration.debug("Not notifying because auto_notify is disabled")
return
end

if !configuration.valid_api_key?
configuration.debug("Not notifying due to an invalid api_key")
return
end
return unless deliver_notification?(exception, auto_notify)

if !configuration.should_notify_release_stage?
configuration.debug("Not notifying due to notify_release_stages :#{configuration.notify_release_stages.inspect}")
return
end

if exception.respond_to?(:skip_bugsnag) && exception.skip_bugsnag
configuration.debug("Not notifying due to skip_bugsnag flag")
return
end
exception = NIL_EXCEPTION_DESCRIPTION if exception.nil?

report = Report.new(exception, configuration, auto_notify)

Expand Down Expand Up @@ -211,6 +197,26 @@ def load_integration(integration)
end
end

private

def deliver_notification?(exception, auto_notify)
reason = abort_reason(exception, auto_notify)
configuration.debug(reason) unless reason.nil?
reason.nil?
end

def abort_reason(exception, auto_notify)
if !configuration.auto_notify && auto_notify
"Not notifying because auto_notify is disabled"
elsif !configuration.valid_api_key?
"Not notifying due to an invalid api_key"
elsif !configuration.should_notify_release_stage?
"Not notifying due to notify_release_stages :#{configuration.notify_release_stages.inspect}"
elsif exception.respond_to?(:skip_bugsnag) && exception.skip_bugsnag
"Not notifying due to skip_bugsnag flag"
end
end

# Check if the API key is valid and warn (once) if it is not
def check_key_valid
@key_warning = false unless defined?(@key_warning)
Expand Down
2 changes: 1 addition & 1 deletion lib/bugsnag/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Bugsnag
class Report
NOTIFIER_NAME = "Ruby Bugsnag Notifier"
NOTIFIER_VERSION = Bugsnag::VERSION
NOTIFIER_URL = "http://www.bugsnag.com"
NOTIFIER_URL = "https://www.bugsnag.com"

UNHANDLED_EXCEPTION = "unhandledException"
UNHANDLED_EXCEPTION_MIDDLEWARE = "unhandledExceptionMiddleware"
Expand Down
15 changes: 15 additions & 0 deletions spec/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,21 @@ def gloops
expect(Bugsnag).not_to have_sent_notification
end

it 'uses an appropriate message if nil is notified' do
Bugsnag.notify(nil)
expect(Bugsnag).to have_sent_notification{ |payload, headers|
event = payload["events"][0]
exception = event["exceptions"][0]
expect(exception["errorClass"]).to eq("RuntimeError")
expect(exception["message"]).to eq("'nil' was notified as an exception")

stacktrace = exception["stacktrace"][0]
expect(stacktrace["lineNumber"]).to eq(1049)
expect(stacktrace["file"]).to end_with("spec/report_spec.rb")
expect(stacktrace["code"]["1048"]).to eq(" it 'uses an appropriate message if nil is notified' do")
expect(stacktrace["code"]["1049"]).to eq(" Bugsnag.notify(nil)")
}
end

if defined?(JRUBY_VERSION)

Expand Down

0 comments on commit dc27a28

Please sign in to comment.