Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Linkcheck Workflow #4545

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

Merged
merged 2 commits into from
Nov 1, 2024
Merged

Fix Linkcheck Workflow #4545

merged 2 commits into from
Nov 1, 2024

Conversation

Bibo-Joshi
Copy link
Member

No description provided.

@Bibo-Joshi Bibo-Joshi added ⚙️ documentation affected functionality: documentation ⚙️ tests affected functionality: tests labels Nov 1, 2024
Copy link

codecov bot commented Nov 1, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
5990 1 5989 271
View the full list of 1 ❄️ flaky tests
tests._files.test_inputfile.TestInputFileWithRequest test_send_bytes

Flake rate in main: 32.77% (Passed 361 times, Failed 176 times)

Stack Traces | 0.491s run time
@contextlib.contextmanager
    def map_httpcore_exceptions() -> typing.Iterator[None]:
        try:
>           yield

C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_transports\default.py:72: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_transports\default.py:377: in handle_async_request
    resp = await self._pool.handle_async_request(req)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <AsyncConnectionPool [Requests: 0 active, 0 queued | Connections: 0 active, 1 idle]>
request = <Request [b'GET']>

    async def handle_async_request(self, request: Request) -> Response:
        """
        Send an HTTP request, and return an HTTP response.
    
        This is the core implementation that is called into by `.request()` or `.stream()`.
        """
        scheme = request.url.scheme.decode()
        if scheme == "":
>           raise UnsupportedProtocol(
                "Request URL is missing an 'http://' or 'https://' protocol."
            )
E           httpcore.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpcore\_async\connection_pool.py:167: UnsupportedProtocol

The above exception was the direct cause of the following exception:

self = <tests.auxil.networking.NonchalantHttpxRequest object at 0x00000211406646E0>
url = 'None', method = 'GET', request_data = None, read_timeout = 5.0
write_timeout = 5.0, connect_timeout = 5.0, pool_timeout = 1.0

    async def do_request(
        self,
        url: str,
        method: str,
        request_data: Optional[RequestData] = None,
        read_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
        write_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
        connect_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
        pool_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
    ) -> tuple[int, bytes]:
        """See :meth:`BaseRequest.do_request`."""
        if self._client.is_closed:
            raise RuntimeError("This HTTPXRequest is not initialized!")
    
        files = request_data.multipart_data if request_data else None
        data = request_data.json_parameters if request_data else None
    
        # If user did not specify timeouts (for e.g. in a bot method), use the default ones when we
        # created this instance.
        if isinstance(read_timeout, DefaultValue):
            read_timeout = self._client.timeout.read
        if isinstance(connect_timeout, DefaultValue):
            connect_timeout = self._client.timeout.connect
        if isinstance(pool_timeout, DefaultValue):
            pool_timeout = self._client.timeout.pool
    
        if isinstance(write_timeout, DefaultValue):
            write_timeout = self._client.timeout.write if not files else self._media_write_timeout
    
        timeout = httpx.Timeout(
            connect=connect_timeout,
            read=read_timeout,
            write=write_timeout,
            pool=pool_timeout,
        )
    
        try:
>           res = await self._client.request(
                method=method,
                url=url,
                headers={"User-Agent": self.USER_AGENT},
                timeout=timeout,
                files=files,
                data=data,
            )

telegram\request\_httpxrequest.py:293: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_client.py:1585: in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_client.py:1674: in send
    response = await self._send_handling_auth(
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_client.py:1702: in _send_handling_auth
    response = await self._send_handling_redirects(
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_client.py:1739: in _send_handling_redirects
    response = await self._send_single_request(request)
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_client.py:1776: in _send_single_request
    response = await transport.handle_async_request(request)
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_transports\default.py:376: in handle_async_request
    with map_httpcore_exceptions():
C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\contextlib.py:162: in __exit__
    self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    @contextlib.contextmanager
    def map_httpcore_exceptions() -> typing.Iterator[None]:
        try:
            yield
        except Exception as exc:
            mapped_exc = None
    
            for from_exc, to_exc in HTTPCORE_EXC_MAP.items():
                if not isinstance(exc, from_exc):
                    continue
                # We want to map to the most specific exception we can find.
                # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to
                # `httpx.ReadTimeout`, not just `httpx.TimeoutException`.
                if mapped_exc is None or issubclass(to_exc, mapped_exc):
                    mapped_exc = to_exc
    
            if mapped_exc is None:  # pragma: no cover
                raise
    
            message = str(exc)
>           raise mapped_exc(message) from exc
E           httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

C:\hostedtoolcache\windows\Python\3.13.0\x64\Lib\site-packages\httpx\_transports\default.py:89: UnsupportedProtocol

The above exception was the direct cause of the following exception:

self = <tests._files.test_inputfile.TestInputFileWithRequest object at 0x000002113D80E990>
bot = PytestExtBot[token=5737018356:AAH138SuiKQF0LDCWsfgWeXfjJ5d63kCWLA]
chat_id = '675666224'

    async def test_send_bytes(self, bot, chat_id):
        # We test this here and not at the respective test modules because it's not worth
        # duplicating the test for the different methods
        message = await bot.send_document(chat_id, data_file("text_file.txt").read_bytes())
        out = BytesIO()
    
>       await (await message.document.get_file()).download_to_memory(out=out)

tests\_files\test_inputfile.py:217: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
telegram\_files\file.py:264: in download_to_memory
    buf = await self.get_bot().request.retrieve(
telegram\request\_baserequest.py:254: in retrieve
    return await self._request_wrapper(
tests\auxil\networking.py:48: in _request_wrapper
    return await super()._request_wrapper(
telegram\request\_baserequest.py:334: in _request_wrapper
    code, payload = await self.do_request(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.auxil.networking.NonchalantHttpxRequest object at 0x00000211406646E0>
url = 'None', method = 'GET', request_data = None, read_timeout = 5.0
write_timeout = 5.0, connect_timeout = 5.0, pool_timeout = 1.0

    async def do_request(
        self,
        url: str,
        method: str,
        request_data: Optional[RequestData] = None,
        read_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
        write_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
        connect_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
        pool_timeout: ODVInput[float] = BaseRequest.DEFAULT_NONE,
    ) -> tuple[int, bytes]:
        """See :meth:`BaseRequest.do_request`."""
        if self._client.is_closed:
            raise RuntimeError("This HTTPXRequest is not initialized!")
    
        files = request_data.multipart_data if request_data else None
        data = request_data.json_parameters if request_data else None
    
        # If user did not specify timeouts (for e.g. in a bot method), use the default ones when we
        # created this instance.
        if isinstance(read_timeout, DefaultValue):
            read_timeout = self._client.timeout.read
        if isinstance(connect_timeout, DefaultValue):
            connect_timeout = self._client.timeout.connect
        if isinstance(pool_timeout, DefaultValue):
            pool_timeout = self._client.timeout.pool
    
        if isinstance(write_timeout, DefaultValue):
            write_timeout = self._client.timeout.write if not files else self._media_write_timeout
    
        timeout = httpx.Timeout(
            connect=connect_timeout,
            read=read_timeout,
            write=write_timeout,
            pool=pool_timeout,
        )
    
        try:
            res = await self._client.request(
                method=method,
                url=url,
                headers={"User-Agent": self.USER_AGENT},
                timeout=timeout,
                files=files,
                data=data,
            )
        except httpx.TimeoutException as err:
            if isinstance(err, httpx.PoolTimeout):
                raise TimedOut(
                    message=(
                        "Pool timeout: All connections in the connection pool are occupied. "
                        "Request was *not* sent to Telegram. Consider adjusting the connection "
                        "pool size or the pool timeout."
                    )
                ) from err
            raise TimedOut from err
        except httpx.HTTPError as err:
            # HTTPError must come last as its the base httpx exception class
            # TODO p4: do something smart here; for now just raise NetworkError
    
            # We include the class name for easier debugging. Especially useful if the error
            # message of `err` is empty.
>           raise NetworkError(f"httpx.{err.__class__.__name__}: {err}") from err
E           telegram.error.NetworkError: httpx.UnsupportedProtocol: Request URL is missing an 'http://' or 'https://' protocol.

telegram\request\_httpxrequest.py:317: NetworkError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

@Bibo-Joshi Bibo-Joshi merged commit 3c8f6ed into master Nov 1, 2024
7 of 23 checks passed
@Bibo-Joshi Bibo-Joshi deleted the fix-lincheck-flow branch November 1, 2024 21:17
@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⚙️ documentation affected functionality: documentation ⚙️ tests affected functionality: tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant