fix(rails): exclude MimeNegotiation::InvalidType by default#160
Open
moladukes wants to merge 3 commits into
Open
fix(rails): exclude MimeNegotiation::InvalidType by default#160moladukes wants to merge 3 commits into
moladukes wants to merge 3 commits into
Conversation
Prompt To Fix All With AIFix 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 |
turnipdabeets
approved these changes
Jun 1, 2026
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.
Matches the iteration pattern used elsewhere in the spec suite (e.g. client_spec.rb:628).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
db25b1e to
c988585
Compare
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.
Closes #159.
MimeNegotiation::InvalidTypeis raised when a client sends a malformedAccept/Content-Typeheader, almost always scanner traffic. Rails maps it to a 406 viaActionDispatch::ExceptionWrapper.rescue_responses, so it's not an app bug. Same category as the already-excludedBadRequest/UnknownFormat/ParseError.default_excluded_exceptionsspec/posthog/rails/configuration_spec.rbbundle exec rspecandbundle exec rubocoppass locally.