-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Downgrade logging of invalid HTTP methods on first request to debug level #10055
Conversation
BadStatusLine is common when a client sends non-HTTP or encrypted traffic to an HTTP port. This is expected to happen when connected to the public internet, so we log it at the debug level so as not to fill logs with noise.
BadStatusLine
to debugBadStatusLine
to debug level
…bad_status_line_logging
I think we can narrow this a bit more. We probably still want exception for aiohttp/aiohttp/_http_parser.pyx Line 835 in 2e369db
|
CodSpeed Performance ReportMerging #10055 will not alter performanceComparing Summary
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #10055 +/- ##
=======================================
Coverage 98.73% 98.73%
=======================================
Files 121 121
Lines 36750 36821 +71
Branches 4391 4393 +2
=======================================
+ Hits 36286 36357 +71
Misses 314 314
Partials 150 150
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
BadStatusLine
to debug level
Would it maybe make sense to call it something like |
We could do something like that with the Py parser, but since the C parser doesn't give an error code other than |
Slept on this one. Still happy with it. Going to do a new patch release since Home Assistant beta is today, and I'll have time to turn fixes for anything that needs to be adjusted this week. Also we will get a lot more testers for 3.11.x in case there is any regressions that were missed. |
Backport to 3.11: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply c11fe96 on top of patchback/backports/3.11/c11fe96f9831f5ab3e4042ce3040424dfc2e4a0d/pr-10055 Backporting merged PR #10055 into master
🤖 @patchback |
Backport to 3.12: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply c11fe96 on top of patchback/backports/3.12/c11fe96f9831f5ab3e4042ce3040424dfc2e4a0d/pr-10055 Backporting merged PR #10055 into master
🤖 @patchback |
…methods on first request to debug level (#10065)
…methods on first request to debug level (#10064)
@bdraco would it be possible to grab the first line of the stream and check it in the error processing branch, re-raising as a gibberish exception? |
This was incorrectly checking the first request ever instead of the first request for the connection #10055 (comment)
Its common when a client sends non-HTTP or encrypted traffic to an HTTP port for the server to encounter an error parsing the request. This is expected to happen when connected to the public internet (rather frequently) as browsers may try to speak SSL before plain-text. There are a variety of other reasons as well, such users mis-typing the port, bad redirects, etc which generates non HTTP traffic on the first request.
To avoid fill logs with noise, a new exception
BadHttpMethod
, which inherits fromBadStatusLine
is now raised internally to distinguish between status lines with invalid versions or status and ones one that start with garbage or an invalid method.The new exception is logged at debug level on the first request only to avoid filling the log with noise when nothing is actually wrong as the vast majority of these are noise. Bad methods received on keep alive requests will continue to be logged at exception level.
Example of how common spurious errors are downstream: https://github.com/home-assistant/core/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aclosed+BadStatusLine https://github.com/home-assistant/core/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen+BadStatusLine
fixes #8065
fixes #8442
fixes #3287