Skip to content

Commit 5bd6eb9

Browse files
authored
fix(scrapy): correct proxy middleware exception log and import (#953)
Fixes in `ApifyHttpProxyMiddleware`: - `process_exception` logged `reason="{exception}"` verbatim because the second line of the message was not an f-string; the actual exception is now interpolated. - Removed the docstring for a non-existent `auth_encoding` argument. - Import `get_basic_auth_header` directly from `apify.scrapy.utils` instead of via the package `__init__` (which is `try_import`-order fragile).
1 parent c4502b6 commit 5bd6eb9

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/apify/scrapy/middlewares/apify_proxy.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from scrapy.exceptions import NotConfigured
88

99
from apify import Actor, ProxyConfiguration
10-
from apify.scrapy import get_basic_auth_header
10+
from apify.scrapy.utils import get_basic_auth_header
1111

1212
if TYPE_CHECKING:
1313
from scrapy import Request, Spider
@@ -30,7 +30,6 @@ def __init__(self, proxy_settings: dict) -> None:
3030
3131
Args:
3232
proxy_settings: Dictionary containing proxy settings, provided by the Actor input.
33-
auth_encoding: Encoding for basic authentication (default is 'latin-1').
3433
"""
3534
self._proxy_settings = proxy_settings
3635
self._proxy_cfg_internal: ProxyConfiguration | None = None
@@ -111,7 +110,7 @@ def process_exception(
111110
if isinstance(exception, TunnelError):
112111
Actor.log.warning(
113112
f'ApifyHttpProxyMiddleware: TunnelError occurred for request="{request}", '
114-
'reason="{exception}", skipping...'
113+
f'reason="{exception}", skipping...'
115114
)
116115

117116
async def _get_new_proxy_url(self) -> ParseResult:

0 commit comments

Comments
 (0)