Skip to content

Commit

Permalink
fix: don't run middleware in Sinatra when not configured (#629)
Browse files Browse the repository at this point in the history
While #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 authored Nov 5, 2024
1 parent 5f78b8a commit d84c2b1
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 d84c2b1

Please sign in to comment.