Skip to content

Conversation

@arthurgousset
Copy link
Member

@arthurgousset arthurgousset commented May 20, 2025

Description

  • fix(rest aiohttp): patch attempt
  • test(ssl bug repro): adds minimal repro test

Other changes

NA

Tested

Root cause: https://hyperdrive.engineering/#report-6a276ba8-f1b7-4e1d-8bae-348b9d127195

Before:

$ python -m pytest tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py
/Users/arthur/Documents/hyperdrive-eng/customers/forks/pinecone-python-client/venv/lib/python3.13/site-packages/pytest_asyncio/plugin.py:217: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
======================================================================================= test session starts ========================================================================================
platform darwin -- Python 3.13.3, pytest-8.3.5, pluggy-1.6.0
rootdir: /Users/arthur/Documents/hyperdrive-eng/customers/forks/pinecone-python-client
configfile: pyproject.toml
plugins: asyncio-0.26.0
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item                                                                                                                                                                                   

tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py F                                                                                                                                 [100%]

============================================================================================= FAILURES =============================================================================================
________________________________________________________________________________ test_ssl_verify_false_causes_error ________________________________________________________________________________

    @pytest.mark.asyncio
    async def test_ssl_verify_false_causes_error():
        """Test that using ssl_verify=False causes an error due to the mutually exclusive
        parameters in aiohttp.TCPConnector constructor."""
    
        # Create a mock configuration with verify_ssl=False
        config = Configuration()
        config.verify_ssl = False
    
        # Passes if no error is thrown, and fails if an error occurs
        try:
>           rest_client = AiohttpRestClient(config)

tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py:21: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pinecone/openapi_support/rest_aiohttp.py:26: in __init__
    conn = aiohttp.TCPConnector(verify_ssl=configuration.verify_ssl, ssl=ssl_context)
venv/lib/python3.13/site-packages/aiohttp/connector.py:867: in __init__
    self._ssl = _merge_ssl_params(ssl, verify_ssl, ssl_context, fingerprint)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

ssl = <ssl.SSLContext object at 0x106621250>, verify_ssl = False, ssl_context = None, fingerprint = None

    def _merge_ssl_params(
        ssl: Union["SSLContext", bool, Fingerprint],
        verify_ssl: Optional[bool],
        ssl_context: Optional["SSLContext"],
        fingerprint: Optional[bytes],
    ) -> Union["SSLContext", bool, Fingerprint]:
        if ssl is None:
            ssl = True  # Double check for backwards compatibility
        if verify_ssl is not None and not verify_ssl:
            warnings.warn(
                "verify_ssl is deprecated, use ssl=False instead",
                DeprecationWarning,
                stacklevel=3,
            )
            if ssl is not True:
>               raise ValueError(
                    "verify_ssl, ssl_context, fingerprint and ssl "
                    "parameters are mutually exclusive"
                )
E               ValueError: verify_ssl, ssl_context, fingerprint and ssl parameters are mutually exclusive

venv/lib/python3.13/site-packages/aiohttp/client_reqrep.py:189: ValueError

During handling of the above exception, another exception occurred:

    @pytest.mark.asyncio
    async def test_ssl_verify_false_causes_error():
        """Test that using ssl_verify=False causes an error due to the mutually exclusive
        parameters in aiohttp.TCPConnector constructor."""
    
        # Create a mock configuration with verify_ssl=False
        config = Configuration()
        config.verify_ssl = False
    
        # Passes if no error is thrown, and fails if an error occurs
        try:
            rest_client = AiohttpRestClient(config)
            # If we get here, no error was thrown, so the test passes
            assert True
        except ValueError as e:
            # If we get here, an error was thrown, so the test fails
>           pytest.fail(f"Expected no error but got: {str(e)}")
E           Failed: Expected no error but got: verify_ssl, ssl_context, fingerprint and ssl parameters are mutually exclusive

tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py:26: Failed
========================================================================================= warnings summary =========================================================================================
tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py::test_ssl_verify_false_causes_error
  /Users/arthur/Documents/hyperdrive-eng/customers/forks/pinecone-python-client/pinecone/openapi_support/rest_aiohttp.py:26: DeprecationWarning: verify_ssl is deprecated, use ssl=False instead
    conn = aiohttp.TCPConnector(verify_ssl=configuration.verify_ssl, ssl=ssl_context)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================================== short test summary info ======================================================================================
FAILED tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py::test_ssl_verify_false_causes_error - Failed: Expected no error but got: verify_ssl, ssl_context, fingerprint and ssl parameters are mutually exclusive
=================================================================================== 1 failed, 1 warning in 0.17s ===================================================================================

After:

$ python -m pytest tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py
/Users/arthur/Documents/hyperdrive-eng/customers/forks/pinecone-python-client/venv/lib/python3.13/site-packages/pytest_asyncio/plugin.py:217: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
======================================================================================= test session starts ========================================================================================
platform darwin -- Python 3.13.3, pytest-8.3.5, pluggy-1.6.0
rootdir: /Users/arthur/Documents/hyperdrive-eng/customers/forks/pinecone-python-client
configfile: pyproject.toml
plugins: asyncio-0.26.0
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item                                                                                                                                                                                   

tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py .                                                                                                                                 [100%]

========================================================================================= warnings summary =========================================================================================
tests/unit/openapi_support/test_rest_aiohttp_ssl_verify.py::test_ssl_verify_false_causes_error
  /Users/arthur/Documents/hyperdrive-eng/customers/forks/pinecone-python-client/pinecone/openapi_support/rest_aiohttp.py:27: DeprecationWarning: verify_ssl is deprecated, use ssl=False instead
    conn = aiohttp.TCPConnector(verify_ssl=False)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=================================================================================== 1 passed, 1 warning in 0.16s ===================================================================================

Related issues

Backwards compatibility

Brief explanation of why these changes are/are not backwards compatible.

Documentation

The set of community facing docs that have been added/modified because of this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] ssl_verify parameter for IndexAsyncio does not work

2 participants