bugsnag 6.27.0 → 6.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2c3cbc7d3aee2477dd5ae66758ea1b76bde5bfd156ce68b35a555de5d82638d
4
- data.tar.gz: 5c093940afd91f221ff636beeea9cb16b855504ff9081a8c8eefee59ec30754c
3
+ metadata.gz: 680c8188ff107f5a9b0a4b973108353d95788732d0eee3f72a065ac31fa652b8
4
+ data.tar.gz: be1bc6969009dc4d3b8e9bd8a8532b6d3045cf043e56487b7c0b2aa8cb01cf84
5
5
  SHA512:
6
- metadata.gz: de4dcfb6fc4688d52ea058d5f82ad31906abd2f54d65b4170646f0a7c06b69d4d39a3e0aee8a35a3dddde4e86a8529e7e425993e52b76f48299e0126f25ff48e
7
- data.tar.gz: 4dbf3896e89cc1cab18928d54145034d0db68cfd41d9e362310f66235982151f2e9672a1df34cc024c294d0426c88a9a2a593d84c726fc7311a6b6ebb23026da
6
+ metadata.gz: 213111ba5278ad9ae1684f74bf5ed2acd5679fb03f0302f619cb8891a96acb14db62ecbd5b751dd82ece54adb8ab96affe5a8710a3dad0e69e52a68df90380f0
7
+ data.tar.gz: 2252e18dc306e89498be738a06bd7c39a1f4ce6569e93896058e7e6b70079acd2e335f9deacc8cec0e36e1ffa2d7885cc6b7e3296540787ad98d78a3273826bb
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## v6.28.0 (8 July 2025)
5
+
6
+ ### Enhancements
7
+
8
+ * Set default endpoints based on API key
9
+ | [#835](https://github.com/bugsnag/bugsnag-ruby/pull/835)
10
+
11
+ ## v6.27.1 (18 June 2024)
12
+
13
+ ### Fixes
14
+
15
+ * Only read Rack request body if it's rewindable
16
+ | [#829](https://github.com/bugsnag/bugsnag-ruby/pull/829)
17
+ * Fix circular require warning
18
+ | [#828](https://github.com/bugsnag/bugsnag-ruby/pull/828)
19
+
4
20
  ## v6.27.0 (23 May 2024)
5
21
 
6
22
  ### Enhancements
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.27.0
1
+ 6.28.0
@@ -1,5 +1,3 @@
1
- require "set"
2
-
3
1
  module Bugsnag::Breadcrumbs
4
2
  class OnBreadcrumbCallbackList
5
3
  def initialize(configuration)
@@ -1,5 +1,3 @@
1
- require 'bugsnag/breadcrumbs/breadcrumbs'
2
-
3
1
  module Bugsnag::Breadcrumbs
4
2
  ##
5
3
  # Validates a given breadcrumb before it is stored
@@ -1,5 +1,3 @@
1
- require 'uri'
2
-
3
1
  module Bugsnag
4
2
  # @api private
5
3
  class Cleaner
@@ -1,20 +1,28 @@
1
- require "set"
2
- require "socket"
3
- require "logger"
4
- require "bugsnag/middleware_stack"
1
+ require "bugsnag/breadcrumbs/on_breadcrumb_callback_list"
2
+
3
+ require "bugsnag/endpoint_configuration"
4
+ require "bugsnag/endpoint_validator"
5
+
6
+ require "bugsnag/middleware/breadcrumbs"
5
7
  require "bugsnag/middleware/callbacks"
8
+ require "bugsnag/middleware/classify_error"
9
+ require "bugsnag/middleware/clearance_user"
10
+ require "bugsnag/middleware/delayed_job"
6
11
  require "bugsnag/middleware/discard_error_class"
7
12
  require "bugsnag/middleware/exception_meta_data"
8
13
  require "bugsnag/middleware/ignore_error_class"
9
- require "bugsnag/middleware/suggestion_data"
10
- require "bugsnag/middleware/classify_error"
14
+ require "bugsnag/middleware/mailman"
15
+ require "bugsnag/middleware/rack_request"
16
+ require "bugsnag/middleware/rails3_request"
17
+ require "bugsnag/middleware/rake"
11
18
  require "bugsnag/middleware/session_data"
12
- require "bugsnag/middleware/breadcrumbs"
19
+ require "bugsnag/middleware/sidekiq"
20
+ require "bugsnag/middleware/suggestion_data"
21
+ require "bugsnag/middleware/warden_user"
22
+
23
+ require "bugsnag/middleware_stack"
24
+
13
25
  require "bugsnag/utility/circular_buffer"
14
- require "bugsnag/breadcrumbs/breadcrumbs"
15
- require "bugsnag/breadcrumbs/on_breadcrumb_callback_list"
16
- require "bugsnag/endpoint_configuration"
17
- require "bugsnag/endpoint_validator"
18
26
 
19
27
  module Bugsnag
20
28
  class Configuration
@@ -191,7 +199,9 @@ module Bugsnag
191
199
 
192
200
  DEFAULT_NOTIFY_ENDPOINT = "https://notify.bugsnag.com"
193
201
  DEFAULT_SESSION_ENDPOINT = "https://sessions.bugsnag.com"
194
- DEFAULT_ENDPOINT = DEFAULT_NOTIFY_ENDPOINT
202
+ HUB_NOTIFY_ENDPOINT = "https://notify.insighthub.smartbear.com"
203
+ HUB_SESSION_ENDPOINT = "https://sessions.insighthub.smartbear.com"
204
+ HUB_PREFIX = "00000"
195
205
 
196
206
  DEFAULT_META_DATA_FILTERS = [
197
207
  /authorization/i,
@@ -241,7 +251,7 @@ module Bugsnag
241
251
  # to avoid infinite recursion when creating breadcrumb buffer
242
252
  @max_breadcrumbs = DEFAULT_MAX_BREADCRUMBS
243
253
 
244
- @endpoints = EndpointConfiguration.new(DEFAULT_NOTIFY_ENDPOINT, DEFAULT_SESSION_ENDPOINT)
254
+ @endpoints = EndpointConfiguration.new(nil, nil)
245
255
 
246
256
  @enable_events = true
247
257
  @enable_sessions = true
@@ -532,6 +542,19 @@ module Bugsnag
532
542
  set_endpoints(notify_endpoint, new_session_endpoint) # Pass the existing notify_endpoint through so it doesn't get overwritten
533
543
  end
534
544
 
545
+ ##
546
+ # Sets the notification and session endpoints to default values if neither have been set
547
+ #
548
+ def set_default_endpoints
549
+ return unless @endpoints.notify.nil? && @endpoints.sessions.nil?
550
+
551
+ self.endpoints = if hub_api_key?
552
+ EndpointConfiguration.new(HUB_NOTIFY_ENDPOINT, HUB_SESSION_ENDPOINT)
553
+ else
554
+ EndpointConfiguration.new(DEFAULT_NOTIFY_ENDPOINT, DEFAULT_SESSION_ENDPOINT)
555
+ end
556
+ end
557
+
535
558
  ##
536
559
  # Sets the notification and session endpoints
537
560
  #
@@ -745,5 +768,9 @@ module Bugsnag
745
768
  # Send the heroku dyno name instead of hostname if available
746
769
  ENV["DYNO"] || Socket.gethostname;
747
770
  end
771
+
772
+ def hub_api_key?
773
+ @api_key && @api_key.start_with?(HUB_PREFIX)
774
+ end
748
775
  end
749
776
  end
@@ -1,5 +1,4 @@
1
1
  require "net/https"
2
- require "uri"
3
2
 
4
3
  module Bugsnag
5
4
  module Delivery
@@ -1,5 +1,3 @@
1
- require "thread"
2
-
3
1
  module Bugsnag
4
2
  module Delivery
5
3
  class ThreadQueue < Synchronous
data/lib/bugsnag/event.rb CHANGED
@@ -1,5 +1,3 @@
1
- require "bugsnag/report"
2
-
3
1
  module Bugsnag
4
2
  # For now Event is just an alias of Report. This points to the same object so
5
3
  # any changes to Report will also affect Event
@@ -1,8 +1,3 @@
1
- require 'uri'
2
- require 'set'
3
- require 'json'
4
-
5
-
6
1
  module Bugsnag
7
2
  module Helpers # rubocop:todo Metrics/ModuleLength
8
3
  MAX_STRING_LENGTH = 3072
@@ -1,5 +1,4 @@
1
1
  require 'mongo'
2
- require 'bugsnag/breadcrumbs/breadcrumbs'
3
2
 
4
3
  module Bugsnag
5
4
  ##
@@ -1,5 +1,3 @@
1
- require 'set'
2
-
3
1
  module Bugsnag::Rails
4
2
  module ActiveJob
5
3
  SEVERITY = 'error'
@@ -1,5 +1,3 @@
1
- require "bugsnag/breadcrumbs/breadcrumbs"
2
-
3
1
  module Bugsnag::Rails
4
2
  DEFAULT_RAILS_BREADCRUMBS = [
5
3
  {
@@ -1,10 +1,6 @@
1
1
  # Rails 3.x hooks
2
2
 
3
- require "json"
4
3
  require "rails"
5
- require "bugsnag"
6
- require "bugsnag/middleware/rails3_request"
7
- require "bugsnag/middleware/rack_request"
8
4
  require "bugsnag/integrations/rails/rails_breadcrumbs"
9
5
 
10
6
  module Bugsnag
@@ -1,4 +1,7 @@
1
- require 'bugsnag'
1
+ # this file can either be required manually by a user, in which case 'bugsnag'
2
+ # needs to be required, or it can be required automatically in the railtie,
3
+ # in which case 'bugsnag' has already been required
4
+ require 'bugsnag' unless defined?(Bugsnag)
2
5
 
3
6
  Rake::TaskManager.record_task_metadata = true
4
7
 
@@ -1,5 +1,3 @@
1
- require "json"
2
-
3
1
  module Bugsnag::Middleware
4
2
  ##
5
3
  # Extracts and attaches rack data to an error report
@@ -17,7 +15,15 @@ module Bugsnag::Middleware
17
15
 
18
16
  request = ::Rack::Request.new(env)
19
17
 
20
- params = request.params rescue {}
18
+ params =
19
+ # if the request body isn't rewindable then we can't read request.POST
20
+ # which is used internally by request.params
21
+ if request.body.respond_to?(:rewind)
22
+ request.params rescue {}
23
+ else
24
+ request.GET rescue {}
25
+ end
26
+
21
27
  client_ip = request.ip.to_s rescue SPOOF
22
28
  session = env["rack.session"]
23
29
 
@@ -106,7 +112,11 @@ module Bugsnag::Middleware
106
112
  end
107
113
 
108
114
  def add_request_body(report, request, env)
109
- body = parsed_request_body(request, env)
115
+ begin
116
+ body = parsed_request_body(request, env)
117
+ rescue StandardError
118
+ return nil
119
+ end
110
120
 
111
121
  # this request may not have a body
112
122
  return unless body.is_a?(Hash) && !body.empty?
@@ -115,26 +125,34 @@ module Bugsnag::Middleware
115
125
  end
116
126
 
117
127
  def parsed_request_body(request, env)
118
- return request.POST rescue nil if request.form_data?
128
+ # if the request is not rewindable then either:
129
+ # - it's been read already and so is impossible to read
130
+ # - it hasn't been read yet and us reading it will prevent the user from
131
+ # reading it themselves
132
+ # in either case we should avoid attempting to
133
+ return nil unless request.body.respond_to?(:rewind)
134
+
135
+ if request.form_data?
136
+ begin
137
+ return request.POST
138
+ ensure
139
+ request.body.rewind
140
+ end
141
+ end
119
142
 
120
143
  content_type = env["CONTENT_TYPE"]
121
144
 
122
145
  return nil if content_type.nil?
146
+ return nil unless content_type.include?('/json') || content_type.include?('+json')
123
147
 
124
- if content_type.include?('/json') || content_type.include?('+json')
125
- begin
126
- body = request.body
148
+ begin
149
+ body = request.body
127
150
 
128
- return JSON.parse(body.read)
129
- rescue StandardError
130
- return nil
131
- ensure
132
- # the body must be rewound so other things can read it after we do
133
- body.rewind
134
- end
151
+ JSON.parse(body.read)
152
+ ensure
153
+ # the body must be rewound so other things can read it after we do
154
+ body.rewind
135
155
  end
136
-
137
- nil
138
156
  end
139
157
 
140
158
  def add_cookies(report, request)
@@ -1,4 +1,3 @@
1
- require "json"
2
1
  require "pathname"
3
2
  require "bugsnag/error"
4
3
  require "bugsnag/stacktrace"
data/lib/bugsnag.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  require "rubygems"
2
2
  require "thread"
3
+ require "set"
4
+ require "json"
5
+ require "uri"
6
+ require "socket"
7
+ require "logger"
3
8
 
4
9
  require "bugsnag/version"
5
10
  require "bugsnag/utility/feature_data_store"
@@ -21,21 +26,9 @@ require "bugsnag/feature_flag"
21
26
  # as it doesn't auto-configure when loaded
22
27
  require "bugsnag/integrations/rack"
23
28
 
24
- require "bugsnag/middleware/rack_request"
25
- require "bugsnag/middleware/warden_user"
26
- require "bugsnag/middleware/clearance_user"
27
- require "bugsnag/middleware/callbacks"
28
- require "bugsnag/middleware/rails3_request"
29
- require "bugsnag/middleware/sidekiq"
30
- require "bugsnag/middleware/mailman"
31
- require "bugsnag/middleware/rake"
32
- require "bugsnag/middleware/classify_error"
33
- require "bugsnag/middleware/delayed_job"
34
-
35
29
  require "bugsnag/breadcrumb_type"
36
30
  require "bugsnag/breadcrumbs/validator"
37
31
  require "bugsnag/breadcrumbs/breadcrumb"
38
- require "bugsnag/breadcrumbs/breadcrumbs"
39
32
 
40
33
  require "bugsnag/utility/duplicator"
41
34
  require "bugsnag/utility/metadata_delegate"
@@ -61,6 +54,8 @@ module Bugsnag
61
54
  def configure(validate_api_key=true)
62
55
  yield(configuration) if block_given?
63
56
 
57
+ configuration.set_default_endpoints
58
+
64
59
  # Create the session tracker if sessions are enabled to avoid the overhead
65
60
  # of creating it on the first request. We skip this if we're not validating
66
61
  # the API key as we use this internally before the user's configure block
@@ -529,8 +524,12 @@ module Bugsnag
529
524
  # If only a notify_endpoint has been set, session tracking will be disabled
530
525
  # If only a session_endpoint has been set, and ArgumentError will be raised
531
526
  def check_endpoint_setup
532
- notify_set = configuration.notify_endpoint && configuration.notify_endpoint != Bugsnag::Configuration::DEFAULT_NOTIFY_ENDPOINT
533
- session_set = configuration.session_endpoint && configuration.session_endpoint != Bugsnag::Configuration::DEFAULT_SESSION_ENDPOINT
527
+ notify_set = configuration.notify_endpoint &&
528
+ configuration.notify_endpoint != Bugsnag::Configuration::DEFAULT_NOTIFY_ENDPOINT &&
529
+ configuration.notify_endpoint != Bugsnag::Configuration::HUB_NOTIFY_ENDPOINT
530
+ session_set = configuration.session_endpoint &&
531
+ configuration.session_endpoint != Bugsnag::Configuration::DEFAULT_SESSION_ENDPOINT &&
532
+ configuration.session_endpoint != Bugsnag::Configuration::HUB_SESSION_ENDPOINT
534
533
  if notify_set && !session_set
535
534
  configuration.warn("The session endpoint has not been set, all further session capturing will be disabled")
536
535
  configuration.disable_sessions
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.27.0
4
+ version: 6.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-23 00:00:00.000000000 Z
11
+ date: 2025-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -107,7 +107,7 @@ homepage: https://github.com/bugsnag/bugsnag-ruby
107
107
  licenses:
108
108
  - MIT
109
109
  metadata:
110
- changelog_uri: https://github.com/bugsnag/bugsnag-ruby/blob/v6.27.0/CHANGELOG.md
110
+ changelog_uri: https://github.com/bugsnag/bugsnag-ruby/blob/v6.28.0/CHANGELOG.md
111
111
  documentation_uri: https://docs.bugsnag.com/platforms/ruby/
112
112
  source_code_uri: https://github.com/bugsnag/bugsnag-ruby/
113
113
  rubygems_mfa_required: 'true'
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.4.10
129
+ rubygems_version: 3.4.19
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Ruby notifier for bugsnag.com