Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RackRequest - don't allow it to crash on bad URLs and only load Sidekiq middleware if running under Sidekiq server #289

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/bugsnag/middleware/rack_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ def call(notification)
# Build the clean url (hide the port if it is obvious)
url = "#{request.scheme}://#{request.host}"
url << ":#{request.port}" unless [80, 443].include?(request.port)
url << Bugsnag::Cleaner.new(notification.configuration.params_filters).clean_url(request.fullpath)

# If app is passed a bad URL, this code will crash attempting to clean it
begin
url << Bugsnag::Cleaner.new(notification.configuration.params_filters).clean_url(request.fullpath)
rescue StandardError => stde
Bugsnag.log "RackRequest - Rescued error while cleaning request.fullpath: #{stde}"
end

headers = {}

Expand Down
9 changes: 7 additions & 2 deletions lib/bugsnag/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@ def call(worker, msg, queue)
end
end

Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Sidekiq)
Bugsnag.configuration.app_type = "sidekiq"
# Only include if running under Sidekiq server; if it is included with Rails (for example)
# it will cause Bugsnag to crash during middleware calls and no meta-data will be sent
# along with application traces sent to the server.
if ::Sidekiq.server?
Bugsnag.configuration.internal_middleware.use(Bugsnag::Middleware::Sidekiq)
Bugsnag.configuration.app_type = "sidekiq"
end