Skip to content

fix(rails): exclude MimeNegotiation::InvalidType by default#160

Open
moladukes wants to merge 2 commits into
PostHog:mainfrom
moladukes:fix/exclude-mime-negotiation-invalidtype
Open

fix(rails): exclude MimeNegotiation::InvalidType by default#160
moladukes wants to merge 2 commits into
PostHog:mainfrom
moladukes:fix/exclude-mime-negotiation-invalidtype

Conversation

@moladukes
Copy link
Copy Markdown

@moladukes moladukes commented May 28, 2026

Closes #159.

MimeNegotiation::InvalidType is raised when a client sends a malformed Accept / Content-Type header, almost always scanner traffic. Rails maps it to a 406 via ActionDispatch::ExceptionWrapper.rescue_responses, so it's not an app bug. Same category as the already-excluded BadRequest / UnknownFormat / ParseError.

  • Adds the class to default_excluded_exceptions
  • Updates the generator template's docs
  • Adds spec/posthog/rails/configuration_spec.rb

bundle exec rspec and bundle exec rubocop pass locally.

Raised when a client sends a malformed Accept or Content-Type header
(typically scanner/fuzzer traffic). Rails maps it to a 406 via
ActionDispatch::ExceptionWrapper.rescue_responses, so it is not an
application bug worth capturing.
@moladukes moladukes requested a review from a team as a code owner May 28, 2026 12:10
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 28, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
spec/posthog/rails/configuration_spec.rb:15-27
The team's coding standard prefers parameterised tests. The two "excludes … by default" examples are identical in structure and are ideal candidates for a shared iteration. A loop-based approach also makes it trivial to extend coverage to every class in `default_excluded_exceptions` without repeating the expectation.

```suggestion
    {
      'ActionController::RoutingError' => ActionController::RoutingError.new('No route matches'),
      'ActionDispatch::Http::MimeNegotiation::InvalidType' =>
        ActionDispatch::Http::MimeNegotiation::InvalidType.new('"foo" is not a valid MIME type')
    }.each do |name, exception|
      it "excludes #{name} by default" do
        expect(config.should_capture_exception?(exception)).to be false
      end
    end
```

Reviews (1): Last reviewed commit: "fix(rails): exclude MimeNegotiation::Inv..." | Re-trigger Greptile

Comment thread spec/posthog/rails/configuration_spec.rb Outdated
Matches the iteration pattern used elsewhere in the spec suite
(e.g. client_spec.rb:628).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

posthog-rails: exclude ActionDispatch::Http::MimeNegotiation::InvalidType by default

1 participant