Repository navigation
7404 - Stop reporting invalid MIME type scanner probes to Scout - #7409
Open
costajohnt wants to merge 1 commit into
Open
costajohnt wants to merge 1 commit into
costajohnt wants to merge 1 commit into
Conversation
costajohnt
requested review from
FireLemons,
compwron and
elasticspoon
as code owners
November 16, 2026 17:26
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What github issue is this PR for, if any?
Resolves #7404
What changed, and why?
Turns out the home page isn't actually returning a 500 for these. Rails already maps
ActionDispatch::Http::MimeNegotiation::InvalidTypeto 406 in its defaultrescue_responses, and I confirmed/and/users/sign_inreturn 406 withproduction-style exception handling (
show_exceptions = :all, no detailed exceptions).What we're seeing is Scout's error middleware. It sits inside the Rails exception
handling and records every exception that passes through it unless the class is in
errors_ignored_exceptions. It doesn't care that Rails turns it into a 4xx.I tried the suggestions in the issue first:
rescue_responses[...] = :not_acceptableis already the Rails default, so it doesn't change anything.rescue_frominApplicationControllerdoesn't catch it. The exception comes fromActionController::Instrumentation#process_actioncallingrequest.format, and thatruns outside
rescue_from.So this adds
ActionDispatch::Http::MimeNegotiation::InvalidTypetoerrors_ignored_exceptionsin the production block ofconfig/scout_apm.yml. Settingthat key replaces Scout's default list, so I added the two defaults back
(
ActiveRecord::RecordNotFound,ActionController::RoutingError).If you'd rather these get rejected before reaching Scout at all, I can switch this
to a small Rack middleware instead. It's more code, and it has to avoid calling
request.formatsbefore routing.How is this tested? (please write rspec and jest tests!) 💖💪
spec/config/scout_apm_spec.rbloadsconfig/scout_apm.ymlfor productionthrough Scout's own config loader and checks its ignore list:
InvalidTypeisignored, the two Scout defaults are still ignored, and a plain
StandardErroris still reported. The
InvalidTypeexample fails against the current configand passes with this change.
spec/requests/static_spec.rb:GET /with a junkAcceptheader and with a junk
Content-Typeheader both return 406. These also pass onmain, so they're regression coverage for the behaviour the issue asked about.
bundle exec rspec spec/requests spec/controllers spec/config(all green) andbundle exec standardrb(clean).Screenshots please :)
No UI changes.