From a0e64bb42b8783a83b2c80ccd899f32cb8691dc2 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 20 Jan 2025 08:27:32 -1000 Subject: [PATCH 1/6] Log the remote that generates request errors (#10332) --- CHANGES/10332.feature.rst | 1 + aiohttp/web_protocol.py | 8 ++++++-- tests/test_web_server.py | 36 +++++++++++++++++++++++++++--------- 3 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 CHANGES/10332.feature.rst diff --git a/CHANGES/10332.feature.rst b/CHANGES/10332.feature.rst new file mode 100644 index 00000000000..e5c84adf50d --- /dev/null +++ b/CHANGES/10332.feature.rst @@ -0,0 +1 @@ +Improved logging of HTTP protocol errors to include the remote address -- by :user:`bdraco`. diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py index 3d76fc1f1d7..613ef91d65e 100644 --- a/aiohttp/web_protocol.py +++ b/aiohttp/web_protocol.py @@ -719,9 +719,13 @@ def handle_error( # 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 as to not fill logs with noise. - self.logger.debug("Error handling request", exc_info=exc) + self.logger.debug( + "Error handling request from %s", request.remote, exc_info=exc + ) else: - self.log_exception("Error handling request", exc_info=exc) + self.log_exception( + "Error handling request from %s", request.remote, exc_info=exc + ) # some data already got sent, connection is broken if request.writer.output_size > 0: diff --git a/tests/test_web_server.py b/tests/test_web_server.py index 12e72b865da..c4a45f732be 100644 --- a/tests/test_web_server.py +++ b/tests/test_web_server.py @@ -67,7 +67,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: assert txt.startswith("500 Internal Server Error") assert "Traceback" not in txt - logger.exception.assert_called_with("Error handling request", exc_info=exc) + logger.exception.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) async def test_raw_server_logs_invalid_method_with_loop_debug( @@ -96,7 +98,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: # on the first request since the client may # be probing for TLS/SSL support which is # expected to fail - logger.debug.assert_called_with("Error handling request", exc_info=exc) + logger.debug.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) logger.debug.reset_mock() # Now make another connection to the server @@ -110,7 +114,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: # on the first request since the client may # be probing for TLS/SSL support which is # expected to fail - logger.debug.assert_called_with("Error handling request", exc_info=exc) + logger.debug.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) async def test_raw_server_logs_invalid_method_without_loop_debug( @@ -139,7 +145,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: # on the first request since the client may # be probing for TLS/SSL support which is # expected to fail - logger.debug.assert_called_with("Error handling request", exc_info=exc) + logger.debug.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) async def test_raw_server_logs_invalid_method_second_request( @@ -170,7 +178,9 @@ async def handler(request: web.BaseRequest) -> web.Response: # BadHttpMethod should be logged as an exception # if its not the first request since we know # that the client already was speaking HTTP - logger.exception.assert_called_with("Error handling request", exc_info=exc) + logger.exception.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) async def test_raw_server_logs_bad_status_line_as_exception( @@ -195,7 +205,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: txt = await resp.text() assert "Traceback (most recent call last):\n" not in txt - logger.exception.assert_called_with("Error handling request", exc_info=exc) + logger.exception.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) async def test_raw_server_handler_timeout( @@ -280,7 +292,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: txt = await resp.text() assert "Traceback (most recent call last):\n" in txt - logger.exception.assert_called_with("Error handling request", exc_info=exc) + logger.exception.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) async def test_raw_server_html_exception( @@ -311,7 +325,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: "\n" ) - logger.exception.assert_called_with("Error handling request", exc_info=exc) + logger.exception.assert_called_with( + "Error handling request from %s", cli.host, exc_info=exc + ) async def test_raw_server_html_exception_debug( @@ -339,7 +355,9 @@ async def handler(request: web.BaseRequest) -> NoReturn: "
Traceback (most recent call last):\n"
     )
 
-    logger.exception.assert_called_with("Error handling request", exc_info=exc)
+    logger.exception.assert_called_with(
+        "Error handling request from %s", cli.host, exc_info=exc
+    )
 
 
 async def test_handler_cancellation(unused_port_socket: socket.socket) -> None:

From 089e7de22fa4cfd6d54209b9a40ae3be76820f71 Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" 
Date: Mon, 20 Jan 2025 08:51:14 -1000
Subject: [PATCH 2/6] Add sphinx configuration for readthedocs (#10339)

---
 .readthedocs.yml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.readthedocs.yml b/.readthedocs.yml
index b3edaf4b8ea..b7d8a9236f6 100644
--- a/.readthedocs.yml
+++ b/.readthedocs.yml
@@ -5,6 +5,10 @@
 ---
 version: 2
 
+sphinx:
+  # Path to your Sphinx configuration file.
+  configuration: docs/conf.py
+
 submodules:
   include: all
   exclude: []

From 755299d0be793c553524859f1ee74204a59a119f Mon Sep 17 00:00:00 2001
From: "J. Nick Koston" 
Date: Mon, 20 Jan 2025 09:59:19 -1000
Subject: [PATCH 3/6] Increase allowed import time for Python 3.12+ (#10342)

---
 tests/test_imports.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test_imports.py b/tests/test_imports.py
index bfcdde3311f..1579135d539 100644
--- a/tests/test_imports.py
+++ b/tests/test_imports.py
@@ -38,7 +38,7 @@ def test_web___all__(pytester: pytest.Pytester) -> None:
         # and even slower under pytest-xdist, especially in CI
         _XDIST_WORKER_COUNT * 100 * (1 if _IS_CI_ENV else 1.53)
         if _IS_XDIST_RUN
-        else 265
+        else 295
     ),
 }
 _TARGET_TIMINGS_BY_PYTHON_VERSION["3.13"] = _TARGET_TIMINGS_BY_PYTHON_VERSION["3.12"]

From 1cc98c72fb1817a5dc0c208cb2d2f641273b0443 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Mon, 20 Jan 2025 21:25:43 +0000
Subject: [PATCH 4/6] Bump cherry-picker from 2.4.0 to 2.5.0 (#10333)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Bumps [cherry-picker](https://github.com/python/cherry-picker) from
2.4.0 to 2.5.0.
Release notes

Sourced from cherry-picker's releases.

cherry-picker-v2.5.0

What's Changed

New Contributors

Full Changelog: https://github.com/python/cherry-picker/compare/cherry-picker-v2.4.0...cherry-picker-v2.5.0

Changelog

Sourced from cherry-picker's changelog.

2.5.0

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=cherry-picker&package-manager=pip&previous-version=2.4.0&new-version=2.5.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/constraints.txt | 6 +++++- requirements/dev.txt | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index db15ec605ad..1c3caea1dfc 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -39,7 +39,7 @@ cfgv==3.4.0 # via pre-commit charset-normalizer==3.4.1 # via requests -cherry-picker==2.4.0 +cherry-picker==2.5.0 # via -r requirements/dev.in click==8.1.8 # via @@ -224,6 +224,10 @@ sphinxcontrib-spelling==8.0.1 ; platform_system != "Windows" # via -r requirements/doc-spelling.in sphinxcontrib-towncrier==0.4.0a0 # via -r requirements/doc.in +stamina==24.3.0 + # via cherry-picker +tenacity==9.0.0 + # via stamina tomli==2.2.1 # via # build diff --git a/requirements/dev.txt b/requirements/dev.txt index 9b4cce59834..f0deae0d02a 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -39,7 +39,7 @@ cfgv==3.4.0 # via pre-commit charset-normalizer==3.4.1 # via requests -cherry-picker==2.4.0 +cherry-picker==2.5.0 # via -r requirements/dev.in click==8.1.8 # via @@ -215,6 +215,10 @@ sphinxcontrib-serializinghtml==2.0.0 # via sphinx sphinxcontrib-towncrier==0.4.0a0 # via -r requirements/doc.in +stamina==24.3.0 + # via cherry-picker +tenacity==9.0.0 + # via stamina tomli==2.2.1 # via # build From 03439a1d118cb634bd1304c305fab5d833ab3a0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 21:27:05 +0000 Subject: [PATCH 5/6] Bump virtualenv from 20.29.0 to 20.29.1 (#10334) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [virtualenv](https://github.com/pypa/virtualenv) from 20.29.0 to 20.29.1.
Release notes

Sourced from virtualenv's releases.

20.29.1

What's Changed

New Contributors

Full Changelog: https://github.com/pypa/virtualenv/compare/20.29.0...20.29.1

Changelog

Sourced from virtualenv's changelog.

v20.29.1 (2025-01-17)

Bugfixes - 20.29.1

- Fix PyInfo cache incompatbility warnings - by
:user:`robsdedude`. (:issue:`2827`)
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=virtualenv&package-manager=pip&previous-version=20.29.0&new-version=20.29.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/constraints.txt | 2 +- requirements/dev.txt | 2 +- requirements/lint.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 1c3caea1dfc..49598ff8c70 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -266,7 +266,7 @@ uvloop==0.21.0 ; platform_system != "Windows" # -r requirements/lint.in valkey==6.0.2 # via -r requirements/lint.in -virtualenv==20.29.0 +virtualenv==20.29.1 # via pre-commit wait-for-it==2.3.0 # via -r requirements/test.in diff --git a/requirements/dev.txt b/requirements/dev.txt index f0deae0d02a..01178e5dd31 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -257,7 +257,7 @@ uvloop==0.21.0 ; platform_system != "Windows" and implementation_name == "cpytho # -r requirements/lint.in valkey==6.0.2 # via -r requirements/lint.in -virtualenv==20.29.0 +virtualenv==20.29.1 # via pre-commit wait-for-it==2.3.0 # via -r requirements/test.in diff --git a/requirements/lint.txt b/requirements/lint.txt index 1528afe9d0a..b69519e1bf4 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -104,5 +104,5 @@ uvloop==0.21.0 ; platform_system != "Windows" # via -r requirements/lint.in valkey==6.0.2 # via -r requirements/lint.in -virtualenv==20.29.0 +virtualenv==20.29.1 # via pre-commit From c68188355abe824acafe32d212e41905d5964059 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 21:37:07 +0000 Subject: [PATCH 6/6] Bump python-on-whales from 0.74.0 to 0.75.1 (#10323) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [python-on-whales](https://github.com/gabrieldemarmiesse/python-on-whales) from 0.74.0 to 0.75.1.
Release notes

Sourced from python-on-whales's releases.

v0.75.1

What's Changed

Full Changelog: https://github.com/gabrieldemarmiesse/python-on-whales/compare/v0.75.0...v0.75.1

v0.75.0

What's Changed

New Contributors

Full Changelog: https://github.com/gabrieldemarmiesse/python-on-whales/compare/v0.74.0...v0.75.0

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=python-on-whales&package-manager=pip&previous-version=0.74.0&new-version=0.75.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/constraints.txt | 2 +- requirements/dev.txt | 2 +- requirements/lint.txt | 2 +- requirements/test.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 49598ff8c70..5a651d8e5bf 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -182,7 +182,7 @@ pytest-xdist==3.6.1 # via -r requirements/test.in python-dateutil==2.9.0.post0 # via freezegun -python-on-whales==0.74.0 +python-on-whales==0.75.1 # via # -r requirements/lint.in # -r requirements/test.in diff --git a/requirements/dev.txt b/requirements/dev.txt index 01178e5dd31..5282e688d2a 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -177,7 +177,7 @@ pytest-xdist==3.6.1 # via -r requirements/test.in python-dateutil==2.9.0.post0 # via freezegun -python-on-whales==0.74.0 +python-on-whales==0.75.1 # via # -r requirements/lint.in # -r requirements/test.in diff --git a/requirements/lint.txt b/requirements/lint.txt index b69519e1bf4..9e4603ed7a2 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -76,7 +76,7 @@ pytest-mock==3.14.0 # via -r requirements/lint.in python-dateutil==2.9.0.post0 # via freezegun -python-on-whales==0.74.0 +python-on-whales==0.75.1 # via -r requirements/lint.in pyyaml==6.0.2 # via pre-commit diff --git a/requirements/test.txt b/requirements/test.txt index fe533c13c36..5c87bae49b0 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -98,7 +98,7 @@ pytest-xdist==3.6.1 # via -r requirements/test.in python-dateutil==2.9.0.post0 # via freezegun -python-on-whales==0.74.0 +python-on-whales==0.75.1 # via -r requirements/test.in rich==13.9.4 # via pytest-codspeed