From e5e1ef3961be5fc331117b0f189834c231f77553 Mon Sep 17 00:00:00 2001 From: Tadas Tamosauskas Date: Mon, 4 Nov 2024 17:37:56 +0000 Subject: [PATCH] fix: don't run middleware in Sinatra when not configured While https://github.com/honeybadger-io/honeybadger-ruby/pull/549 has removed middleware loading for Rails unless configured, it has also removed the code that prevented the middleware from executing unless configured. A similar change is also required for Sinatra, because currently it tries to execute when not configured. When a Sinatra app does not use i18n gem and has user feedback disabled, it errs with a "I18n::InvalidLocale - :en is not a valid locale" exception from ERB, because Honeybadger tries to render the feedback form. --- lib/honeybadger/init/sinatra.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/honeybadger/init/sinatra.rb b/lib/honeybadger/init/sinatra.rb index ca52b1fd..6cb8923e 100644 --- a/lib/honeybadger/init/sinatra.rb +++ b/lib/honeybadger/init/sinatra.rb @@ -31,8 +31,8 @@ def install_honeybadger if config[:'exceptions.enabled'] # These two must come before the ErrorNotifier, since an error/response # passes through middleware from inner to outer (bottom to top) - install_honeybadger_middleware(Honeybadger::Rack::UserFeedback) - install_honeybadger_middleware(Honeybadger::Rack::UserInformer) + install_honeybadger_middleware(Honeybadger::Rack::UserFeedback) if config[:'feedback.enabled'] + install_honeybadger_middleware(Honeybadger::Rack::UserInformer) if config[:'user_informer.enabled'] install_honeybadger_middleware(Honeybadger::Rack::ErrorNotifier) end end