Skip to content
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

[Bug] ssl_verify parameter for IndexAsyncio does not work #465

Open
2 tasks done
williamhakim10 opened this issue Feb 24, 2025 · 2 comments
Open
2 tasks done

[Bug] ssl_verify parameter for IndexAsyncio does not work #465

williamhakim10 opened this issue Feb 24, 2025 · 2 comments
Labels
bug Something isn't working status:needs-triage An issue that needs to be triaged by the Pinecone team

Comments

@williamhakim10
Copy link

Is this a new bug?
In other words: Is this an error, flaw, failure or fault? Please search Github issues and check our Community Forum to see if someone has already reported the bug you encountered.

If this is a request for help or troubleshooting code in your own Pinecone project, please join the Pinecone Community Forum.

  • I believe this is a new bug
  • I have searched the existing Github issues and Community Forum, and I could not find an existing post for this bug

Describe the bug

When instantiating a new async index with ssl_verify=False, e.g.:

async with pc.IndexAsyncio(
    host="localhost:5081", name="test-index", ssl_verify=False
) as idx:
    yield idx

API calls (specifically update, but probably all the others) do not work because aiohttp TCP Connectors require verify_ssl or ssl_context but not both. See https://github.com/aio-libs/aiohttp/blob/v3.9.0/aiohttp/client_reqrep.py#L169. The solution probably looks something like this, see in

if configuration.ssl_ca_cert is not None:

if verify_ssl:
        if configuration.ssl_ca_cert is not None:
            ca_certs = configuration.ssl_ca_cert
        else:
            ca_certs = certifi.where()

        ssl_context = ssl.create_default_context(cafile=ca_certs)
        conn = aiohttp.TCPConnector(verify_ssl=True, ssl=ssl_context)
else:
        conn = aiohttp.TCPConnector(verify_ssl=False)

You could also use a more modern version of aiohttp which doesn't have these legacy ssl parameters.

Error information

../embeddings/pinecone_writer.py:170: in update_metadata
    async with self.index_async(model_id=model_id, catalog=catalog_id) as idx:
../../../../.pyenv/versions/3.10.13/lib/python3.10/contextlib.py:199: in __aenter__
    return await anext(self.gen)
../embeddings/pinecone_writer.py:147: in index_async
    async with self.__client.IndexAsyncio(
../../../../Library/Caches/pypoetry/virtualenvs/embeddings-A5ycbq_j-py3.10/lib/python3.10/site-packages/pinecone/control/pinecone.py:332: in IndexAsyncio
    return _IndexAsyncio(
../../../../Library/Caches/pypoetry/virtualenvs/embeddings-A5ycbq_j-py3.10/lib/python3.10/site-packages/pinecone/data/index_asyncio.py:150: in __init__
    self._vector_api = setup_async_openapi_client(
../../../../Library/Caches/pypoetry/virtualenvs/embeddings-A5ycbq_j-py3.10/lib/python3.10/site-packages/pinecone/utils/setup_openapi_client.py:12: in setup_async_openapi_client
    api_client = api_client_klass(configuration=openapi_config)
../../../../Library/Caches/pypoetry/virtualenvs/embeddings-A5ycbq_j-py3.10/lib/python3.10/site-packages/pinecone/openapi_support/asyncio_api_client.py:39: in __init__
    self.rest_client = AiohttpRestClient(configuration)
../../../../Library/Caches/pypoetry/virtualenvs/embeddings-A5ycbq_j-py3.10/lib/python3.10/site-packages/pinecone/openapi_support/rest_aiohttp.py:24: in __init__
    conn = aiohttp.TCPConnector(verify_ssl=configuration.verify_ssl, ssl=ssl_context)
../../../../Library/Caches/pypoetry/virtualenvs/embeddings-A5ycbq_j-py3.10/lib/python3.10/site-packages/aiohttp/connector.py:867: in __init__
    self._ssl = _merge_ssl_params(ssl, verify_ssl, ssl_context, fingerprint)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

ssl = <ssl.SSLContext object at 0x131598ac0>, 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

Environment

  • OS Version: MacOS Sonoma 14.3
  • Python version: Python 3.10.13
  • Python SDK version: 6.0.1
@williamhakim10 williamhakim10 added the bug Something isn't working label Feb 24, 2025
@github-actions github-actions bot added the status:needs-triage An issue that needs to be triaged by the Pinecone team label Feb 24, 2025
@mcpaddy
Copy link

mcpaddy commented Feb 27, 2025

Hello @williamhakim10,

Thank you for raising the bug report. Pinecone Local does not support TLS/SSL. This means that when you connect to it from one of the Pinecone SDKs, the protocol needs to be set in the host parameter, like so:

async with pc.IndexAsyncio(
    host="http://localhost:5081", name="test-index"
) as idx:
    yield idx

That said, I do think this could be a valid bug when using a proxy, where one might need to disable certificate validation.

@williamhakim10
Copy link
Author

Hi @mcpaddy - thanks for your response. Your example does indeed work. The confusing part (for us) is that we have code like this:

host = pc.describe_index(index_name).host
async with pc.IndexAsyncio(host=host, ...) as idx:
    yield idx

Normally this works fine, because describe_index returns a host without a scheme, and any host without a scheme is assumed to be https:// by the index. However, in the case of Pinecone Local, SSL isn't supported, so you get an SSL error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status:needs-triage An issue that needs to be triaged by the Pinecone team
Projects
None yet
Development

No branches or pull requests

2 participants