Skip to content

Commit

Permalink
Do not load middleware that's not configured in Sinatra
Browse files Browse the repository at this point in the history
While honeybadger-io#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.
  • Loading branch information
tadast committed Nov 4, 2024
1 parent 5ddaf95 commit e79f7d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/honeybadger/init/sinatra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e79f7d1

Please sign in to comment.